Name |
Description |
Example |
Add (expr) |
Add the elements matching the expression to the jQuery object. This function can be used to connect the element result set that matches the two expressions respectively. |
Dynamically generate an element and add it to the matching element: $ ("P"). add ("<span> Again </span> ") |
Children ([expr]) |
Obtains the element set of all child elements of each element in a matched element set. You can use an optional expression to filter matched child elements. Note: parents () searches for all ancestor elements, while children () only considers child elements, not all descendant elements. |
Find each child element in the DIV: $ ("Div"). children () |
Closest ([expr]) |
Obtain the latest parent element matching the expression. |
Change the style of the parent class li object closest to the event Source: $ (Document). bind ("click", function (e ){ Criteria (e.tar get). closest ("li"). toggleClass ("hilight "); }); |
Contents () |
Search for all child nodes (including text nodes) within the matching element ). If the element is an iframe, search for the document content |
Search for all text nodes and bold them: $ ("P"). contents (). not ("[nodeType = 1]"). wrap ("<B/> "); |
Find (expr) |
Searches for all elements that match the specified expression. This function is a good way to find the child element of the element being processed. All searches rely on jQuery expressions. This expression can be written using the selector syntax of the CSS1-3. |
Search for the following span element from all paragraphs. Same as $ ("p span: $ ("P"). find ("span ") |
Next ([expr]) |
Obtains the Element Set of the Peer element next to each element in a matched element set. This function only returns the next peer element, instead of all peer elements (nextAll can be used ). You can use an optional expression for filtering. |
Find the peer element next to each paragraph: $ ("P"). next () |
NextAll ([expr]) |
Find all peer elements after the current element. You can use expressions to filter data. |
Add a class to all elements after the first div: $ ("Div: first"). nextAll (). addClass ("after "); |
OffsetParent () |
Returns the first parent class with a location (such as relative or absolute )). |
|
Parent ([expr]) |
Obtains a set of elements that contain the unique parent element of all matching elements. You can use an optional expression to filter data. |
Find the parent element of each paragraph: $ ("P"). parent () |
Parents ([expr]) |
Obtains a set of elements (excluding the root element) that contain all the ancestor elements matching the elements ). You can use an optional expression to filter data. |
Find all the ancestor elements of each span element: $ ("Span"). parents () |
Prev ([expr]) |
Obtains the Element Set of the first peer element next to each element in a matched element set. You can use an optional expression for filtering. Only peer elements that are adjacent to each other will be matched, instead of all peer elements. |
Find the first peer element next to each paragraph: $ ("P"). prev () |
PrevAll ([expr]) |
Find all peer elements before the current element You can use expressions to filter data. |
Add a class to all previous divs: $ ("Div: last"). prevAll (). addClass ("before "); |
Siblings ([expr]) |
Obtains the element set of all unique peer elements of each element in a matched element set. You can use an optional expression for filtering. |
Find all peer elements of each div: $ ("Div"). siblings () |