Possible Duplicate:
Can jQuery provide the tag name?
Hi!
This question is so basic i am ashamed asking but i tried to find the answer for 30 minutes without any result.
How do i find out what kind of element has been clicked in the code below.
$('*').click(function (event) {
var this_element = $(this).???;
return false;
})
What i am looking for is to have the this_element variable set to 'a' if it's a link, 'p' if it's a paragraph 'div' if...
Thanks!
event.stopPropagation();
to stop your click from being passed along to parent elements for no good reason. see the api docs: api.jquery.com/get – Suhreturn false;
in jQuery event handles.stopPropagation()
and.preventDefault()
– Incommunicable