I have a problem with the jQuery click event when an element is inside another element. The code I am using is similar to the following:
<div class="a" id="a">
<a class="b" id="b"></a>
</div>
$(".a,.b").click(function() {
var current_id = $(this).attr("id");
alert(current_id);
...do something...
});
When I click on the tag class="b" it returns the encapsulated class="a" id instead of the id of class="b". How do I code it so that when I click on class="a" or class="b" it returns the correct corresponding id value?