O'Reilly logo

jQuery and JavaScript Phrasebook by Brad Dayley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Getting the Event Target Objects

function myHandler(e){   //get the value of the object that triggered the event   var originalValue = $(e.target).val();   //get the value of the current object   var currentValue = $(e.currentTarget).val();   //get the inner HTML of the current object   var currentHTML = $(this).html(); }

The event object provides a link to the DOM object that originally triggered the event as the event .target attribute. The event object also provides a link to the DOM object that triggered the current event handler as the event.currentTarget attribute. Having access to these objects is useful because it allows you to obtain additional information, such as checked state or value.

The object ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required