I have a simple html snippet.
<div class="group">
<div class="A1_B1 symptom">
<ul><li><a href="#" class="hit">Click Symptom</li></ul>
</div>
<div class="A2_B2 remedy">
<ul><li><a href="#" class="hit">Click Remedy</li></ul>
</div>
</div>
Now for the click action...
$(document).on("click", ".hit", function (ev) {
if($(this).parents(".symptom"))
alert("Symptom Clicked");
if($(this).parents(".remedy"))
alert("Remedy Clicked");
});
$(this) is supposed to refer only the element that I have clicked. Why does it alert both the alert statements even if the if conditions do not satisfy?