Jquery Property Traversal,HTML operations.
Jquery has a powerful way to manipulate HTML elements and attributes.
Here are some of the jquery traversal functions I've compiled:
. Add () |
Adds an element to the collection of matching elements. |
. Andself () |
Adds the previous set of elements in the stack to the current collection. |
. Children () |
Gets all the child elements of each element in the matching element collection. |
. Closest () |
Starting with the element itself, it is progressively matched to the ancestor element and returns the first matching ancestor element. |
. Contents () |
Gets the child elements of each element in the matching element collection, including the text and comment nodes. |
. each () |
Iterates over the JQuery object and executes the function for each matching element. |
. End () |
Ends the most recent filter operation in the current chain and returns a collection of matching elements to the previous state. |
. EQ () |
Reduces the collection of matching elements to a new element at the specified index. |
. Filter () |
Reduces the set of matching elements to a new element that matches the selector or the return value of the matching function. |
. Find () |
Gets the descendants of each element in the current matching element collection, filtered by the selector. |
. First () |
Reduces the collection of matching elements to the first element in the collection. |
. has () |
Reduces the collection of matching elements to a collection of descendants that contain a particular element. |
. is () |
Checks the current set of matching elements based on the selector, and returns true if at least one of the matching elements exists. |
. Last () |
Reduces the collection of matching elements to the last element in the collection. |
. Map () |
Passes each element in the current matching collection to the function, producing a new JQuery object that contains the return value. |
. Next () |
Gets the sibling element adjacent to each element in the matching element collection. |
. Nextall () |
Gets all the sibling elements after each element in the matching element collection, optionally filtered by selectors. |
. Nextuntil () |
Get all the sibling elements after each element until you encounter the element that matches the selector. |
. Not () |
Removes an element from the collection of matching elements. |
. OffsetParent () |
Gets the first parent element used for positioning. |
. Parent () |
Gets the parent element of each element of the current matching element collection, optionally filtered by the selector. |
. Parents () |
Gets the ancestor element of each element in the current matching element collection, optionally filtered by the selector. |
. Parentsuntil () |
Gets the ancestor element of each element in the current matching element collection until it encounters an element that matches the selector. |
. Prev () |
Gets the previous sibling element immediately adjacent to each element in the matching element collection, optionally filtered by the selector. |
. Prevall () |
Gets all sibling elements before each element in the matching element collection, optionally filtered by selectors. |
. Prevuntil () |
Get all of the sibling elements before each element until you encounter the element that matches the selector. |
. Siblings () |
Gets the sibling elements of all elements in the matching element collection, optionally filtered by the selector. |
. Slice () |
Reduces the collection of matching elements to a subset of the specified range. |
These are my insights into the jquery traversal function.
HTML methods for manipulating the DOM :
JqueryThe most important part is the OperationDOMthe ability tojqueryprovides a range ofDOMrelated methods, which make it easy to access and manipulate the properties of the elements and properties, how to manipulateDOMobject:Document Object Model(Document Object model)DOMDefine AccessHTMLand theXMLStandard for Documentation: " theThe Document Object model is independent of the Platform and language interface, allowing programmers and scripts to dynamically access and update document content, structure, and style. ”。 Dom gets-tex (), HTML (), and Val ()three simple and practical forJQuery method for DOM manipulation: text ()-Sets or returns the text content of the selected element HTML ()-Sets or returns the contents of the selected element (including HTML tags) val ()-Sets or returns the value of the form field gets the property-attr ()
The JQuery attr () method is used to get the property value.
To set the contents of all P elements:
$ (". Btn1"). Click (function () {
$ ("P"). html ("Hello <b>world</b>!");
});
When you use this method to return a value, it returns the contents of the first matching element.
$ (selector). HTML ()
When you use this method to set a value, it overrides the contents of all matching elements.
$ (selector). html (content)
Use a function to set the contents of all matching elements.
$ (selector). HTML (function (index,oldcontent))
The above is my understanding of jquery properties, traversal, HTML operations, and I hope to help you.
jquery properties, traversal, HTML operations