I'm trying to find out a way to know the index of a anchor tag inside a certain div (one div has multiple similar anchor tags), like this :
<div>
<a>first</a>
<a>second</a>
<a>third</a>
</div>
I'm using jQuery, but so far found no sollution to find the index of the anchor I have the mouse currently over.
Any ideas?
Cheers!
This should work
$('div a').mouseover(
function(){
alert( $('div a').index(this) );
}
);
some changes would be required if there are multiple divs with links inside them and you want to find the index in that specific group..
$("div a").hover(function() {
var index = $(this).index();
});
This is what you mean, am I correct?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.