I want get information about the currently clicked html element. For that I used $(*).click() event so that every element on the page will have this event.
suppose I have following html code
<div class="outer">
<div class="inner">
<p>Hello<p>
</div>
</div>
now when user clicks hello I want to get that element so that I could identify its tag, its class etc.
But here is the problem, when user clicks on hello, click event get fired but it get fired on p tag , then div class=inner and then on div with class as outer . But here i want to get event only on the text or area where user has clicked.
I want get information about the currently clicked html element. For that I used
Share
Please use
$(document).click()instead of$(*).click()and usee.targetto get specified.element.
You can stop the event bubbling by using
e.stopPropagation();DEMO: http://jsfiddle.net/Q6cpR/1/