Michael
Michael

Reputation: 33307

Jquery delegate Scroll event on position fixed element

I have the following html code:

<div id="scroll-box">
    <div id="header" style="position:fixed">...</div>
    <div id="main">...</div>
</div>

I tried to delegate the scroll event of the scroll-box event if the user scrolls with the mouse over the header:

$('#scroll-box').delegate('#header', 'scroll', function(){
    alert("scroll");
    });

This is not working. How can I trigger the scroll event of the scroll-box even if the mouse is over the header and the user scrolls?

Upvotes: 1

Views: 1211

Answers (1)

John Kurlak
John Kurlak

Reputation: 6680

You can't delegate the scroll event because the scroll event doesn't bubble. Delegation works only for events that bubble.

Upvotes: 2

Related Questions