php - How to remove scrow follow javascript when screen width changes -


i have javascript code going go on wordpress cms in index.php file of theme (see javascript code below). have succeeded in making scroll work, when resize window (when responsiveness sets in) banner goes way left of screen. had thought disabling javascript plain div tag, responsiveness work. figured out if disable javascript @ point when width of containing tag less 600 make work (by removing javascript). not work.

i not sure javascript solution best solution. can help? suggestions welcomed...

<script type = "text/javascript" >  $(document).ready(function () {     var $sidebar = $(".follow-scroll"),         $window = $(window),         offset = $sidebar.offset(),         toppadding = 20;     $window.scroll(function () {         //disable javascript if width larget less 600         if ($('.outern').width() < 600) {             return;         } else {             //enable scroll folowing feature otherwise             if ($window.scrolltop() > offset.top) {                 $sidebar.stop().animate({                     margintop: $window.scrolltop() - offset.top + toppadding                 });             } else {                 $sidebar.stop().animate({                     margintop: 20                 });             }         }     }); }); </script> 

thank you

jquery's resize() listens when windows width/height changes.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -