Let’s say I do something stupid like this:
<div class="my_class">fun wee!!</div>
<span class="my_class"><b class="my_class">Title</b></span>
<p class="my_class">Client</p>
<Script>
$('.my_class').click(function() {
alert('You clicked a ??????? Tag!!');
});
</script>
Where I have selected lots of different tags with the same selector. How do i figure out what tag was selected?
Seems like something simple but I haven’t yet found an answer…
In jQuery event handlers, ‘this’ is set to the DOM node on which the event was triggered. So you’d want:
The W3C DOM spec has more info: http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247