modify event data during propagation

The event object that is passed by jQuery is a wrapper around the native event object. The bubbling happens at the javascript/browser level and hence the native event object seems to be shared among all the event handlers.

$('div').click(function(e) {
    e.originalEvent.attribute =  (e.originalEvent.attribute || "") + 
        " " + $(this).prop("className");
    alert(e.originalEvent.attribute);
});

Tested in Chrome, Firefox, Safari, IE9 and IE10. If you test in other browsers please comment with the results.

Here’s the fiddle: http://jsfiddle.net/5AQqD/

Leave a Comment

tech