i have a this function to count the index number, but i need to count it from it’s parents parent, so my result of index would be 0,1,2.
how can i do this?
myfuntion://
html:
<div id="parent">
<div class="child1">
<h3>title one</h3>
</div>
<div class="child1">
<h3>title one</h3>
</div>
<div class="child1">
<h3>title one</h3>
</div>
</div>
Jquery:
$('h3','#parent').click(function(){
alert($(this).index('#parent'))
})
change your function with
example fiddle: http://jsfiddle.net/HwySz/