Home  >  Article  >  Web Front-end  >  Jquery index()方法 获取相应元素索引值_jquery

Jquery index()方法 获取相应元素索引值_jquery

WBOY
WBOYOriginal
2016-05-16 17:49:151110browse

index([subject])方法,返回值:Number(从0开始计数)
index()方法返回指定元素相对于其他指定元素的 index 位置。注释:如果未找到元素,index() 将返回 -1。

复制代码 代码如下:







请点击下面的按钮,以获得 id="favorite" 的元素相对于 jQuery 选择器 (class="hot") 的 index:


  • Milk

  • Tea

  • Coffee




Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn