How to get the ID of the element that fired an event ?
- The target property can be the element that listed for the event or a child of it.
- It is useful to compare
thisin order to determine if the event is being handled due to event bubbling.
- This property is useful in event delegation, when events bubble.
To use a jQuery function, you must refer to it as
Read AlsoEvent bubbling and capturing
You can use this code:
$(event.target).idgives the id attribute.
event.target.idalso gives the id attribute.
this.idgives the id attribute
"id" is a DOM function so you have to be on the DOM element object to use it.