JQuery index of element in selector

this is pseudo code

  var index_of_myid = $('.selection').indexOf($('#myid));

Not sure if this is correct, it is possible if you can understand what I'm trying to do

EDIT

 <div>
    <div class="selector"></div>
 </div>
 <div>
    <div class="selector"></div>
 </div>
 <div>
    <div class="selector" id="myid"></div>
 </div>
 <div>
    <div class="selector" id="myid2"></div>
 </div>

I just need to know which number selector is myid

+5
source share
1 answer

Of course you want to use jQuery indexas opposed to indexOfthe JS String method:

var index_of_myid = $('.selection').index($('#myid'));

See http://api.jquery.com/index/

+7
source

All Articles