views:

204

answers:

1

I want to access the original event object but the object returns undefined..

$(window).scroll(function(event) {
     alert(event.pageX);
    });

I'm just trying this out if it will work. The example is as basic as possible so I can work out other events too.

+6  A: 

One thing to be careful is not to use the word event as a name of a parameter (or a variable) because in some browsers (like IE and Chrome), event is already an object, and if you use it you will be overwritten the already existing function.

Thus, try changing your code to this :

$(window).scroll(function(ev) {
    alert(ev.pageX);
});
Andreas Grech