2

When using for events for internet explorer we are currently using statements like this to access or change values:

window.event.cancelBubble = true;
clickX = window.event.screenX;

I was wondering how to do this cross browser or using JQuery?

4

1 回答 1

2

When you provide a callback to a jquery binding function, it always take as first parameter a event that you should use, even on IE.

Don't use window.event if you're using jQuery.

Note that this is a jQuery wrapped event. For some uses you may need the originalEvent property of the event you get. Here's how you can get both in a callback :

​$('#A').click(function(e){
    console.log(e); // jquery event
    console.log(e.originalEvent); // native event
});​
于 2012-10-25T08:23:35.587 回答