Name |
Description |
Example |
Add (expr) |
Adds an element that matches an expression to a jquery object. This function can be used to concatenate the result set of an element that matches two expressions respectively. |
Dynamically generates an element and adds it to the matching element: $ ("P"). Add ("Again") |
Children ([expr]) |
Gets a collection of elements that contains all the child elements of each element in the matching element collection. The matching child elements can be filtered by an optional expression. Note: parents () finds all ancestral elements, whereas children () considers only child elements regardless of all descendant elements. |
Find each child element in the DIV: $ ("div"). Children () |
Closest ([expr]) |
Gets the most recent parent element that matches the expression |
To change the style of the nearest parent class Li object for the event source: $ (document). Bind ("click", Function (e) { $ (e.target). Closest ("Li"). Toggleclass ("Hilight"); }); |
Contents () |
Finds all child nodes (including text nodes) within a matching element. If the element is an IFRAME, find the document content |
Find all text nodes and add bold: $ ("P"). Contents (). Not ("[nodetype=1]"). Wrap (""); |
Find (expr) |
Searches for all elements that match the specified expression. This function is a good way to find out the descendant elements of the element being processed. All searches are done using jquery expressions. This expression can be written using Css1-3 's selector syntax. |
Starting with all the paragraphs, search further for the following span element. Same as $ ("P span"): $ ("P"). FIND ("span") |
Next ([expr]) |
Gets a collection of elements that contain the next sibling element immediately following each element in the matching element collection. This function only returns the next sibling element, not all of the siblings behind it (you can use Nextall). You can filter with an optional expression. |
Find the sibling elements that are immediately behind each paragraph: $ ("P"). Next () |
Nextall ([expr]) |
Finds all sibling elements after the current element. can be filtered with an expression |
Add a class to all elements after the first div: $ ("Div:first"). Nextall (). addclass ("after"); |
OffsetParent () |
Returns the first parent that has a location (for example (relative or absolute)). |
|
Parent ([expr]) |
Gets a collection of elements that contain the unique parent element for all matching elements. You can use an optional expression to filter. |
Find the parent element for each paragraph: $ ("P"). Parent () |
Parents ([expr]) |
Gets a collection of elements containing the ancestor elements of all matching elements (without the root element). You can filter by an optional expression. |
Find all the ancestor elements of each span element: $ ("span"). Parents () |
Prev ([expr]) |
Gets a collection of elements that contain the first sibling element immediately adjacent to each element in the matching element collection. You can filter with an optional expression. Only the immediate sibling elements are matched to, not all of the preceding sibling elements. |
Find the previous sibling element that is adjacent to each paragraph: $ ("P"). Prev () |
Prevall ([expr]) |
Finds all sibling elements before the current element can be filtered with an expression. |
Add a class to all the div before the last one: $ ("Div:last"). Prevall (). addclass ("before"); |
Siblings ([expr]) |
Gets a collection of elements that contain all unique sibling elements of each element in the matching element collection. You can filter by using an optional expression. |
Find all the sibling elements of each div: $ ("div"). Siblings () |