我无法访问单击的对象(此)父类..单击相同的元素和不同的返回?
HTML
<div class="rows row1">
<div class="ele">1</div>
<div class="ele">1</div>
<div class="ele">1</div>
</div>
<div class="rows row2">
<div class="ele">2</div>
<div class="ele">2</div>
<div class="ele">2</div>
</div>
jQuery
$('.ele').click(function() {
if ( $(this).parent().hasClass('r1') ) {//way1
alert('you clicked 1st row element');
}
else if ( $(this).parent().hasClass('r2') === true ) {//both way wont work
alert('you clicked 2nd row element');
}
});
</p>