Home  >  Article  >  Web Front-end  >  Example of usage of eq() method in jQuery_jquery

Example of usage of eq() method in jQuery_jquery

WBOY
WBOYOriginal
2016-05-16 16:22:031179browse

The example in this article describes the usage of the eq() method in jQuery. Share it with everyone for your reference. The specific analysis is as follows:

This method can get the element with the corresponding position index on the matching element set.
The position index of the element in the matching element set starts from 0.

Grammar structure:

Copy code The code is as follows:
$(selector).eq(index)

Parameter list:

参数 描述
index 定义元素在元素集中的索引,从零开始的。
如果是负数则从最后一个元素往回计数。
越界无效。

Example code:

Example 1:

Copy code The code is as follows:






eq() method-Script Home






  • HTML Zone

  • Javascript Zone

  • Div Css Zone

  • Jquery Zone





Set the font color in the li element with index 1 to blue.

Example 2:

Copy code The code is as follows:






Click pop-up window effect-Script Home







  • HTML Zone

  • Javascript Zone

  • Div Css Zone

  • Jquery Zone





When the index is negative, count backwards from the last element.

I hope this article will be helpful to everyone’s jQuery programming.

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