Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use eq in jquery

Shulou Source: shulou.com Published: 2022-06-02 06:59:32 09月30日 Update

This article introduces the knowledge of "how to use eq in jquery". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Eq means: 1, ": eq ()" selector, this selector can select the element with the specified index value, syntax is "$(": eq (index) ")"; 2, "eq ()" traversal method, this method can return the element with the specified index number of the selected element, the syntax is "$(element) .eq (index)".

The operating environment of this tutorial: windows10 system, jquery3.2.1 version, Dell G3 computer.

What does eq mean in jquery

1. It represents the eq () selector.

The eq () selector selects the element with the specified index value.

The index value starts at 0, and the index value for all the first elements is 0 (not 1).

It is often used with other elements / selectors to select elements with a specific ordinal number in a specified group.

Examples are as follows:

$(document) .ready (function () {$("p:eq (1)") .css ("background-color", "# B2E0FF");}); Welcome to My HomepageMy name is Donald

I live in Duckburg

My best friend is Mickey

Who is your favourite:GoofyMickeyPluto

Output result:

2. It represents the eq () traversal method.

The eq () method returns the element with the specified index number of the selected element.

The index number starts with 0, so the index number of the first element is 0 (not 1).

Examples are as follows:

(document) .ready (function () {$("p") .eq (1) .css ("background-color", "yellow");}); Welcome to my homepage

My name is Donald (subscript 0).

Donald Duck (index 1).

I live in Duckburg (index 2).

My best friend is Mickey (index 3).

Output result:

This is the end of the content of "how to use eq in jquery". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Elements selections methods indexes index numbers output content meaning more knowledge examples results grammar practicality achievement next subscript home page name dilemma Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi MariaDB Shulou Technology Apple Huawei