开发者

jQuery index of item in selector

开发者 https://www.devze.com 2023-01-11 16:32 出处:网络
this is pseudo code var index_of_myid = $(\'.selection\').indexOf($(\'#myid)); not sure if this is right is this possible if you can understand wha开发者_如何学Ct I\'m trying to do

this is pseudo code

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

not sure if this is right is this possible if you can understand wha开发者_如何学Ct 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 what number selector is the myid


Surely you mean to be using jQuery's index as opposed to the indexOf JS string method:

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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消