NOTE:- We can use the
index()
method on mouseenter()
:<div class="sub">
<div class="count">First Div</div>
</div>
<div class="count">Second Div</div>
<div class="count">Third Div</div>
<div class="count">Fourth Div</div>
<div class="count">Fifth Div</div>
<div class="count">Six Div</div>
<div class="count">Seven Div</div>
<div class="output"></div>
<script>
$('.count').mouseenter(function(){
var idp = $(this).index('.count') + 1;
$('.output').text('Current Position is: ' + idp);
});
</script>
No comments:
Post a Comment