Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
24
rated 0 times [  26] [ 2]  / answers: 1 / hits: 63262  / 13 Years ago, mon, january 16, 2012, 12:00:00
$(window).click(function(e) {
alert(e.???);
});


How can I check how id, class or other identifiers of the current click?


More From » jquery

 Answers
25

The event object gives you a target property that refers to the actual element clicked, and a currentTarget property that refers to the element to which the handler was bound.



Those elements are represented as DOM nodes, which are just objects with their own properties, which enable to you to access certain aspects of the state of the element.



$(window).click(function(e) {
alert(e.target.id); // gives the element's ID
alert(e.target.className); // gives the elements class(es)
});

[#88003] Friday, January 13, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
johnnyblaynes

Total Points: 667
Total Questions: 121
Total Answers: 102

Location: Anguilla
Member since Sat, Jan 23, 2021
3 Years ago
;