javascript - Bootstrap Modal Background Scrolling Issue -


when bootstrap modal window open, have been unable stop background scrolling main page. followed directions given in stackoverflow question, have been unsuccessful far: prevent body scrolling when modal opened

on left side, near top of page, after loads, see button says "large modal". if click it, open modal window. after open, if scroll , down, see background moving. http://gettinmobile.com/home.html

i have added css directed in stackoverflow question linked above:

body.modal-open {     overflow: hidden; } 

i have added javascript shown on same stackoverflow question, though not sure done correctly:

   <script type='text/javascript'>     $("#mymodal").on("show", function () {      $("body").addclass("modal-open");    }).on("hidden", function () {      $("body").removeclass("modal-open")    });    </script> 

any appreciated, maybe can see i'm doing wrong... thanks!

you need wait jquery finish loading before start binding events. can anonymous function:

$(function(){     // current js code here }); 

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 -