1: eq(index) method
is used to get the Nth element. The position of this element starts from 0. The syntax format is as follows: eq(index)
Get the third table and set its background color to "#FCF", the code is as follows: $("td").eq(2).css("background", "#FCF");
2: filter(expr) method
is used to filter out the set of elements that match the specified expression, and is used to narrow the scope of the match. Use commas to separate multiple expressions, then there is an "OR" relationship between multiple expressions,
The syntax is as follows: filter(expr)
$("input").filter(".sel").css("backgroud", "#FCF"); //Select the input element with the class attribute value sel and set its background color
$("input").filter(".sel, :first").css("background", "#FCF"); //Select input elements with class attribute values or select elements in the current field first element and set their background color,
Separate expressions with commas
3: filter(fn) method
is used to filter out the set of elements that match the return value of the specified function. The function will internally calculate each object once (such as $:each). If the called function returns false, the element will be deleted,
Otherwise it will be retained. The syntax format is as follows: filter(fn)
How are you?
is used to retain elements that contain specific descendants and remove elements that do not contain the specified descendants. This method will recreate a set of matching objects from the given jQuery object. The provided selector will test the original
one by one. 🎜>Descendants of those objects, objects containing matching descendants will be retained, the syntax format is as follows:
has(expr)
5: hasClass(class)
用于检查当前的元素是否含有某个特定的类,如果有,则返回true
6:map(callback)方法
map(callback)方法用于将一组元素转换成其他数组(无论是否是元素数组), 可以用这个函数来建立一个列表,无论是值、属性还是CSS样式,或者其他特别形式,
都可以用$.map()来方便的建立,语法格式如下:
map(callback)