Jquery attribute traversal,HTML operations.
Jquery has a powerful way to manipulate HTML elements and attributes.
Here are some of the jquery traversal functions I've sorted out:
. Add () |
Adds an element to the collection of matching elements. |
. Andself () |
Adds the set of elements before the stack to the current collection. |
. Children () |
Gets all the child elements of each element in the matching element collection. |
. Closest () |
Starts with the element itself, recursively matches the ancestor element, and returns the first matching ancestral element. |
. Contents () |
Gets the child elements of each element in the matching element collection, including text and annotation nodes. |
. each () |
Iterate over the JQuery object, executing the function for each matching element. |
. End () |
Ends the most recent filter operation in the current chain and returns a collection of matching elements back to the previous state. |
. EQ () |
Reduces the collection of matching elements to the new element at the specified index. |
. Filter () |
Reduces the collection of matching elements to a new element that matches the return value of a selector or matching function. |
. Find () |
Gets the descendants of each element in the current matching element collection, filtered by the selector. |
. A () |
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 specific elements. |
. is () |
Checks the collection of current matching elements according to the selector, and returns True if there is at least one matching element. |
. Last () |
Reduces the collection of matching elements to the last element in the collection. |
. Map () |
Passes each element in the current matching collection to a function, generating a new JQuery object that contains the returned value. |
. Next () |
Gets the sibling elements that are adjacent to each element in the matching element collection. |
. Nextall () |
Gets all sibling elements after each element in the collection of elements, which is filtered by the selector (optional). |
. Nextuntil () |
Gets all sibling elements after each element until the element that matches the selector is encountered. |
. Not () |
Deletes an element from the collection of matching elements. |
. offsetparent () |
Gets the first parent element to use for positioning. |
. Parent () |
Gets the parent element of each element in 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 the element that matches the selector is encountered. |
. Prev () |
Gets the first sibling element next to each element in the matching element collection, filtered by selector (optional). |
. Prevall () |
Gets all sibling elements before each element in the matching element collection, which is filtered by the selector (optional). |
. Prevuntil () |
Gets all the sibling elements before each element until the element that matches the selector is encountered. |
. Siblings () |
Gets the sibling element of all elements in the matching element collection, which is filtered by the selector (optional). |
. Slice () |
Reduces the set of matching elements to a subset of the specified range. |
These are my insights into the jquery traversal function.
HTML Operations DOM method:
The most important part of jquery is the ability to manipulate the Dom , which provides a series of Dom -related methods, This makes it easy to access and manipulate the attributes ' elements and attributes, how to manipulate the DOM object:Document Object Model DOM Define Access HTML and XML Standard for documents: " The Consortium The Document Object model is independent of platform and language interfaces, allowing programmers and scripts to dynamically access and update document content, structure, and style. ”。 Dom gets-tex (), HTML (), and Val () three simple and useful jQuery methods for DOM operations: Text ()-Sets or returns the text content HTML () of the selected element-Sets or returns the contents of the selected element, including HTML tag) Val ()-Sets or returns the value of the form field get Properties-attr ()
The JQuery attr () method is used to get the property value.
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 set a value using this method, it overwrites the contents of all matching elements.
$ (selector). HTML (content)
Use functions to set the contents of all matching elements.
$ (selector). HTML (function (index,oldcontent))
That's my understanding of jquery attributes, traversal, HTML operations, and hopefully it will help.
About this jquery attribute, traversal, HTML operation method is small series to share all the content, hope to give you a reference, but also hope that we support cloud habitat community.