vendredi 3 juillet 2020

Only use jquery if screen size is less than

I have jQuery code that is only used for a toggle menu that appears when the screen is less than 991px. Because of this I only want the jQuery code to be used when the screen size is less that 991px. I have tried adjusting the code a few times, but nothing is working. Any help would be appreciated.

my code -

jQuery(document).ready(function() {
  jQuery('.footer__section-header__ovrYO').click(function() {
    jQuery(this).siblings(".footer__section-links__2LOtr").toggle();
  });
});

I've tried adding in if

jQuery(document).ready(function() {
  if($(window).width() <= 991){
  jQuery('.footer__section-header__ovrYO').click(function() {
    jQuery(this).siblings(".footer__section-links__2LOtr").toggle();
  }
  });
});

Aucun commentaire:

Enregistrer un commentaire