Node access methods: 1. children(), which can access all direct child elements of the selected element; 2. closest(), which can access the first ancestor element of the selected element; 3. find( ), which can access the descendant elements of the selected element; 4. first(), which can access the first element of the selected element; 5. last(), etc.
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
Methods that jquery can access to nodes
Method | Description |
---|---|
add() | Add elements to the set of matching elements |
addBack() | Add the previous set of elements to the current set |
children() | Returns all direct child elements of the selected element |
closest() | Returns the first ancestor element of the selected element |
contents() | Returns all direct children of the selected element Elements (containing text and comment nodes) |
each() | Execute the function |
end( for each matching element ) | End the latest filtering operation in the current chain, and return the set of matching elements to the previous state |
eq() | Return Element with the specified index number of the selected element |
filter() | Reduces the set of matching elements to new elements that match the return value of the selector or matching function |
find() | Returns the descendant elements of the selected element |
first() | Returns the selected element Select the first element of the element |
has() | Returns all elements that have one or more elements inside it |
is() | Checks the set of matching elements based on the selector/element/jQuery object, and returns true if there is at least one matching element |
last() | Returns the last element of the selected element |
map() | Pass each element in the current matching set to the function to generate A new jQuery object that returns the value |
next() | Returns the next sibling element of the selected element |
nextAll () | Returns all sibling elements after the selected element |
nextUntil() | Returns the elements between the two given parameters All sibling elements after each element |
not() | Remove the element from the set of matching elements |
offsetParent() | Returns the first positioned parent element |
parent() | Returns the direct parent element of the selected element |
parents() | Returns all ancestor elements of the selected element |
parentsUntil() | Returns between two All ancestor elements between the given parameters |
prev() | Returns the previous sibling element of the selected element |
prevAll() | Returns all sibling elements before the selected element |
prevUntil() | Returns between two given elements All sibling elements before each element between the parameters |
siblings() | Returns all sibling elements of the selected element |
slice() | Reduce the set of matching elements to a subset of the specified range |
There are generally seven methods to access and query sibling elements: siblings(), next(), nextAll(), nextUntil(), prev(), prevAll(), prevUntil()
siblings() method, mainly used to obtain all elements at the same level of the specified element
next() method, mainly used to obtain the next sibling of the specified element Element
nextAll() method, mainly used to obtain all elements of the next sibling level of the specified element
nextUntil() method, mainly Used to obtain the next sibling element of the specified element. This sibling element must be the element between the specified element and the element set by the nextUntil() method.
prev() method, mainly Used to obtain the upper-level sibling elements of the specified element
prevAll() method, mainly used to obtain all the sibling elements at the upper level of the specified element
The prevUntil() method is mainly used to obtain the previous sibling element of the specified element. This sibling element must be the element between the specified element and the element set by the prevUntil() method
Example:
siblings() method
##next() method
prev() method
ul (父节点)
- li (兄弟节点)
- li (类名为"start"的li节点的上一个兄弟节点)
- li (类名为"start"的li节点)
- li (兄弟节点)
- li (兄弟节点)
jQuery video tutorial,web front-end]
The above is the detailed content of What methods does jquery have for accessing nodes?. For more information, please follow other related articles on the PHP Chinese website!