What does “eq” in the jquery .eq() method stand fo

2020-08-09 05:00发布

问题:

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.

回答1:

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."



回答2:

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".



回答3:

I think of it as *e*lement *q*ueue.



回答4:

i always think eq is short of sequence :)



标签: jquery