event.target
JQ 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.target | The value of the DOM element, or descendant thereof, that initiated the event. |
Parameters
None.
Return
A DOM element.
event.target
Example
Objects << Top
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.
Related Tutorials
jQuery Advanced Tutorials - Lesson 5 - The Event Object