Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "eq" in the jquery .eq() method stand for?

Tags:

jquery

example:

$("td:eq(2)").css("color", "red"); or $('td').eq(2).css("color", "red"); 

I want to know what the abbreviation "eq" stands for, I am not asking what the .eq() method does, which can be found here.

Regarding the importance of the question: I myself find it easier to learn a language, when I know what certain abbreviations really stand for. And I also sometimes "read" my written code aloud using "real" words.

like image 690
drkthng Avatar asked Feb 25 '13 02:02

drkthng


People also ask

What is the difference between eq () and get () methods in jQuery?

eq() returns it as a jQuery object, meaning the DOM element is wrapped in the jQuery wrapper, which means that it accepts jQuery functions. . get() returns an array of raw DOM elements. You may manipulate each of them by accessing its attributes and invoking its functions as you would on a raw DOM element.

Which of the following CSS selectors will select the second div in jQuery?

Using jQuery :eq() Selector To select the 2nd element of li, you have to use 2 as the argument.

How use contains in jQuery?

jQuery :contains() SelectorThe :contains() selector selects elements containing the specified string. The string can be contained directly in the element as text, or in a child element. This is mostly used together with another selector to select the elements containing the text in a group (like in the example above).

What is the following syntax is used to apply not equal filter on HTML elements using jQuery?

The not() is an inbuilt function in jQuery which is just opposite to the filter() method. This function will return all the element which is not matched with the selected element with the particular “id” or “class”.


2 Answers

eq() makes sense if you know it's part of a related set of selectors (from the JQuery docs):

The index-related selectors (:eq(), :lt(), :gt(), :even, :odd) filter the set of elements that have matched the expressions that precede them.

When lined up next to lt (less than), and gt (greater than), it's clear that it means equals, specifically "index equals n".

like image 121
Plynx Avatar answered Oct 21 '22 00:10

Plynx


I have always assumed that .eq() is short for "equals." Many (perhaps even most) common English-language words that start with "eq" have the equi- prefix, rooted in the Latin word for "equals."

like image 35
Matt Ball Avatar answered Oct 21 '22 00:10

Matt Ball