mercredi 15 juin 2016

Get index of jquery object within another jquery object


Suppose

<div class='foo' id='a'></div>
<div class='foo' id='b'></div>
<div class='foo' id='c'></div>

var foos = $('.foo');

we can get the first foo if we want

var myFoo = $(foos.get(0));

Now that we have myFoo, how can we do the opposite to get its index?

var index = foos.getIndexOf(myFoo);


Aucun commentaire:

Enregistrer un commentaire