I think this should be simple but I haven’t been able to figure it out:
I have a container with a couple of children:
<div id='container'>
<div id='one'>some</div>
<div id='two'>random</div>
<div id='three'>text</div>
</div>
I want to be able to know the position of say element $(‘#two’)… which should return 2 (as the element is the second of the container’s children, $(‘#one’)…. should return 1 and so on.
Thanks a lot in advance,
Martin
You can use jQuery.index for this:
Note that the index is zero-based.