Mark Fondy Mark Fondy - 3 years ago 140
Javascript Question

$(window).click(function(e) - identifier of currently clicked element

$(window).click(function(e) {

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

Answer Source

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(; // gives the element's ID 
    alert(; // gives the elements class(es)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download