Jquery selector (original) <4>, original jquery Selector
I learned the basic selector. Now I want to learn the simple filter selector in the filter selector:
Simple filter selectors mainly filter elements based on index values. These filter selectors are similar to CSS pseudo-class selectors. They all start with a colon (:) and must be used with another selector.
1. The first selector filters the current jquery set and selects the first Matching Element. The syntax format is as follows:
$ ("Selector: first ")
The selector parameter indicates any valid selector.
2.: last Selector
: Last selector, which filters the current jquery set and selects the last matching element. The syntax format is as follows.
$ ("Selector: last ")
The selector parameter indicates any valid selector.
<! DOCTYPE html>
3. odd Selector
: Odd selector, used to select all elements with an odd index (counting from 0). The syntax is as follows:
$ ("Selector: odd ")
The selector parameter indicates any valid selector. DOM elements, the index value in the jquery set starts from 0, so the index values of 2nd, 4th, and sixth are 1, 3, 5, and so on.
4.: enen Selector
: Even selector, used to select all elements with an even index (counted from 0). Syntax format:
$ ("Selector: even ")
The selector parameter indicates any valid selector. DOM elements, the index value in the jquery set starts from 0, so the index values of 1st, 3rd, and 5th are respectively 0, 2, 4, and so on.
<! DOCTYPE html>
5.: eq () Selector
: The eq () selector is used to select the element whose index is equal to the given value from the matching set. The syntax format is as follows:
$ ("Selector: eq (index )")
The index starts from 0;
6. gt () Selector
: The gt () selector is used to select all elements whose indexes are greater than the given value from the matching set. The syntax format is as follows:
$ ("Selector: gt (index )")
The index starts from 0.
7.: lt () Selector
: Lt () selector is used to select all elements whose indexes are smaller than the given value from the matching set. The syntax format is as follows:
$ ("Selector: lt (" index ")")
The index starts from 0.
8.: not () Selector
: Not () selector, used to remove all elements that match the given selector from a matched set. Syntax format:
$ ("Selector1: not (selector2 )")
Eg: $ ("td: not (: first,: last )")
9.: header Selector
: Header selector, used to select all title elements such as h1, h2, and h3. Syntax format:
$ (": Header ")
Eg: $ (": header?#.css (" color "," red ");
10.: animated Selector
: The animated selector is used for all elements that are executing an animation. The syntax format is as follows:
$ ("Selector: animated ")
The selector indicates any valid selector.