How to disable Jquery function when window width smaller than X -
i'm newbie, , couldn't work. i'm not sure i'm doing wrong. checked other answers issue on stack overflow, still couldn't manage disable resizing on scroll function, depending on screen width.
i want function stop working when screen width smaller 900 px.
any appreciated
<script> $(function(){ $('.nav').data('size','big'); }); $(window).scroll(function(){ var $nav = $('.nav'); if ($('body').scrolltop() > 0) { if ($nav.data('size') == 'big') { $nav.data('size','small').stop().animate({ height:'40px' }, 600); $('.nav-collapse li a').css('height','40px'); } } else { if ($nav.data('size') == 'small') { $nav.data('size','big').stop().animate({ height:'80px' }, 600); $('.nav-collapse li a').css('height','80px'); } } }); </script>
<script> var limiter = 900; $(function(){ $('.nav').data('size','big'); }); $(window).scroll(function(){ if ( $(window).width() > limiter ) { // here go var $nav = $('.nav'); if ($('body').scrolltop() > 0) { if ($nav.data('size') == 'big') { $nav.data('size','small').stop().animate({ height:'40px' }, 600); $('.nav-collapse li a').css('height','40px'); } } else { if ($nav.data('size') == 'small') { $nav.data('size','big').stop().animate({ height:'80px' }, 600); $('.nav-collapse li a').css('height','80px'); } } } }); </script>
Comments
Post a Comment