return FALSE; $r = well_tag_thread__update(array('id' => $id), $update); return $r; } function well_tag_thread_find($tagid, $page, $pagesize) { $arr = well_tag_thread__find(array('tagid' => $tagid), array('id' => -1), $page, $pagesize); return $arr; } function well_tag_thread_find_by_tid($tid, $page, $pagesize) { $arr = well_tag_thread__find(array('tid' => $tid), array(), $page, $pagesize); return $arr; } ?>javascript - jquery: find out at which position (order) a particular element is among its neighbors - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jquery: find out at which position (order) a particular element is among its neighbors - Stack Overflow

programmeradmin4浏览0评论

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

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

Share Improve this question asked Jan 30, 2011 at 16:47 HoffHoff 39.9k17 gold badges83 silver badges104 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

You can use jQuery.index for this:

$('#two').index() // 1

Note that the index is zero-based.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论