简体   繁体   中英

Fire event on scrolling an open bootstrap modal

I am using "Bootstrap" modal (actually a branch of it that disables background scrolling when the modal is shown and adds more features - "bootstrap-modalmanager").

I need to do something when the modal is being scrolled. The problem is I can't find what is actually being scrolled.

When I use Chrome dev tools I can see in the time-line the event "scroll" is bring fired but I can't find where to see the div it scrolls, which I need to know so that I can do:

this:

 $(window).on('scroll',"THE ID I AM LOOKING FOR",function(){..})

or this:

 $("THE ID I AM LOOKING FOR").on('scroll',function(){..})

You can look for the target element in the event object. This will tell you where the event was fired.

$(document).on('scroll', function(e) {
    e.target; //e.target will be the DOM element where the scroll event was fired
});

You can pass a different jQuery selector to the 'on' event according to your requirements.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM