event.targetS2C Home « Objects « event.target

Event target initiation property.

Description

The event.target Event object property, contains the value of the DOM element, or descendant thereof, that initiated the event.

  • This property is useful for comparing with the this special operator, in order to determine whether the event is being handled because of event bubbling.

Syntax

Signature Description
event.targetThe value of the DOM element, or descendant thereof, that initiated the event.

Parameters

None.

Return

A DOM element.

event.target ExampleTop

Contains the value of the DOM element, or descendant thereof, that initiated the event.

When we press the mouse button in the division below with an id of 'div12' a message is output displaying the target element.



$(function(){
  $('#div12').on('click', function(event) {
    $('#div12').append('--The ' + event.target.nodeName + ' element was clicked.<br/ >');
 });
});

div12. Some initial text.