Scrolling jquery.on not working

I am trying to create a DOM event recorder to reproduce how a user interacts with a page. I would like to use the jquery.on function so that I can record all the events on the page. In this particular case, I am trying to record scroll events, but ultimately I want to record all kinds of events.

Here is a link to my JS Fiddle. I expect the text "Hello" to change to "Bye" after the user scrolls through the div.

http://jsfiddle.net/MnpPM/

Herel is html

<div id="parent" style="height: 300px; width: 300px; overflow: scroll">
    <div style="height: 500px; width: 500px">
        Hello
    </div>
</div>

and here javascript

$(document).on('scroll', '*', function () { $(this).html('Bye') });
+5
source share
2 answers

the event is scrollnot propagated through dom, so you cannot use it with a delegate.

scroll, :

$(function() {
     $("#parent").on('scroll', function () { $(this).html('Bye') });
});
+6

t.niese, mouseenter mouseleave - , jsfiddle, , - , , , .

http://jsfiddle.net/MnpPM/30/

:

var scrollCount = 0;
$('body').on('mouseenter','*',function(e){
    console.log('mouseenter');
    $(this).scroll(function(){
           scrollCount++;
           console.log('Current Count:'+scrollCount);
    });   
    $(this).mouseout(function() {
      $(this).unbind();
    }); 
});

div, , .

+1

All Articles