How to only reference one element when using .live("click" with elements within each other?
- by think123
Suppose I have the following code:
<div id="outerrt">
<div id="rt" style="width: 200px; height: 200px; border: 1px solid black;">
<span id="rt2">content</span>
</div>
</div>
And I use the following:
$("#outerrt *").live("click", function () {
alert($(this).attr('id'));
});
What it would give me when I click on the content text is three alert windows, in the following order:
rt2
rt
outerrt
What I actually want it to give me is only one id: rt2. How do I accomplish that?