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 ...

Get jQuery and JavaScript Phrasebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.