I have this in my page:
<div id="container">
<div>
<p>...</p>
<a href="#" class></a>
</div>
<div>
<p>...</p>
<a href="#" class="checked"></a>
</div>
<div>
<p>...</p>
<a href="#" class></a>
</div>
</div>
Now, I want some codes to execute when each of the a elements changes its class. This doesn't work:
$('#food_container').click( function() {
if ($('#food_container a').attr('class') == "checked") {
/* some codes */
}
});
How to fix this? Thanks!
.hasClass('checked')to check if the element has the class.