Does anyone know how to select any element (possibly on click) on page like body is selected, div is selected, div#foo etc… so i can place it to some variable and edit it later on.
i’ve tried
$("*", document.body).click(function (e) {
e.stopPropagation();
var domEl = $(this).get(0);
alert("Clicked on - " + domEl.tagName);
});
but it’s not working for all elements
You want to get the
targetproperty of the event:See: http://www.quirksmode.org/js/events_properties.html
Demo: http://jsfiddle.net/karim79/dyHEA/