I ask a specific question about jquery scroll events, but it seems like the answer could have implications to jquery events in general (which I am also interested in knowing).
Suppose that jquery plugin A
(e.g., jquery.scrollspy.js) binds a scroll event to $(window)
Now say that some site imports plugin A
, but it also has its own custom javascript file B
, which binds another .scroll()
event to $(window)
.
Later on, javascript file B
wants to unbind its own scroll event, and leave jquery plugin A
intact. How is this done?
and...
Is this method universal to all jquery events?
jQuery recommends to use on and off instead of bind and unbind.
function scrollEvent()
{
}
$(window).on('scroll',scrollEvent);
$(window).off('scroll',scrollEvent);
http://api.jquery.com/on/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With