0

I want to add a class to an element when the screen width is smaller than 979px. Also when the screen is adjusting and wider than 979px, above added class should be removed.

This is the code I've tried, but its not working.

$(document).ready(function(){
   if(screen.width < 979) {
       $('.social').addClass('hide');
   }
});

Please help me fix this.

Thanks and Regards.

4

2 に答える 2

2

これを試して:

$(document).ready(function () {
  $(window).resize(function () {
    if ($(window).width() < 979) {
      $('.social').addClass('hide');
    } else {
      $('.social').removeClass('hide');
    }
  });
});
于 2013-01-15T05:03:33.653 に答える
1

これが必要なものだと思います: resize

于 2013-01-15T05:03:18.673 に答える