why not delegate work to scroll?
Since the scroll event does not go through the DOM.
But , in modern browsers (IE> 8) you can capture a scroll event , for example, at the document level or any static container for a dynamic element. You must use the javascript addEventListener() method, passing true as the useCapture parameter, jQuery does not support the capture phase:
Note: in your example, the scroll event occurs at #parent level, not #child
document.addEventListener('scroll', function (event) { if (event.target.id === 'parent') {
For an explanation of the differences between event capture / propagation, see here or there .
Remember that a captured event always fires before any other bubbling event of the same type.
A. Wolff May 27 '15 at 7:55 2015-05-27 07:55
source share