Reputation: 20444
Using JQuery how do we find what the current nth:child the element being clicked is and alert that number.
$('.bouncetabs a').click(function(){
alert($(this + ':nth-child'))
return false
});
Obviously that does not work. How do we do it?
Upvotes: 2
Views: 1849
Reputation: 27647
I think you want the .index method:
var selector = '.bouncetabs a';
$(selector).click(function(){
//just .index() may work too, depending on the html
alert($(this).index(selector));
return false;
});
Upvotes: 4