Usage and comparison of Jquery:eq selector and EQ () methods

Source: Internet
Author: User

: EQ (Index)

An element that matches a given index value

Index: Counting starting from 0

$ ("UL Li:eq (3)")//element of index position 0 starts counting, so here's 3 actually for the 4th element

$ ("ul"). Find ("Li"). EQ (3) //Using jquery Traversal method eq ()

EQ (index|-index)

get the first n Elements

Index

An integer that indicates the position of the element based on 0, and the position of the element is calculated from 0.

-index

An integer that indicates the position of the element, starting from the last element in the collection. (1 count)

Gets the second element of a match

<p> this was just a test.</p> <p> so is this</p>

$ ("P"). EQ (1) or $ ("P"). EQ (-1)

Apps:tab tab

If

$ (' Div.tab_box > div ')//Select child nodes

. EQ (index). Show (). siblings (). Hide ();

This will enable the tab switch effect,

if $ (' Div.tab_box > Div:eq (Index) ')

. Show (). siblings (). Hide ()

You can't switch.

Explain:

:eq () selector to write variable, that is, index is dynamic change, you need to use + + connection,

that is:$ ('div.tab_box > Div:eq ('+index+')')

Note: The preceding quotation marks are a pair, the following quotation marks are a pair, or you can precede a pair of quotation marks with double quotes, followed by single quotes.

both of these methods enable the Dynamic Selection tab tab.


This article is from the "7540036" blog, please be sure to keep this source http://7550036.blog.51cto.com/7540036/1859893

Usage and comparison of Jquery:eq selector and EQ () methods

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.