The example in this article describes the usage of the end() method in jQuery. Share it with everyone for your reference. The specific analysis is as follows:
The
end() method can go back to before the latest "destructive" operation, that is, change the matching element list to the previous state.
If there are no destructive operations an empty set will be returned.
The concept of destructive operations: refers to any operation that changes the matched elements. Maybe everyone is vague about this concept. Here is an example:
$("li").css("color","red");
The CSS function in the above code is not a destructive operation, because the list of matching elements does not change, but the CSS properties of the text content in the element are changed.
$("li").find(".first")
The above code is a destructive operation because the list of matching elements has changed. For example, if there are three li elements, then the list of matching elements has three elements. However, after filtering using the find() method, the list of matching elements has only one element. This is where a "destructive" operation occurs.
Grammar structure:
$(selector).end()
Example code:
Script Home
- HTML Zone
- Javascript Zone
- Div Css Zone
- Jquery Zone
- HTML Zone
- Javascript Zone
- Div Css Zone
- Jquery Zone
- HTML Zone
- Javascript Zone
- Div Css Zone
- Jquery Zone
I hope this article will be helpful to everyone’s jQuery programming.