I have a problem with click event; here's the code:
jQuery:
$(document).ready(function() {
$('.myClass').click(function() {
alert($(.myClass).attr("iditem"));
});
});
HTML:
<div class="myClass" iditem="1">
1
</div>
<div class="myClass" iditem="2">
2
</div>
Two DIV with same class, but different values for the same attribute, when I click on a DIV, alert print always "1" (it seems ignoring the declaration of second DIV). Why .attr() doesn't take the right value for the second DIV?