Home > Web Front-end > JS Tutorial > body text

Example of usage of end() method in jQuery_jquery

WBOY
Release: 2016-05-16 16:21:26
Original
1156 people have browsed it

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:

Copy code The code is as follows:
$("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.
Copy code The code is as follows:
$("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:

Copy code The code is as follows:
$(selector).end()

Example code:

Copy code The code is as follows:






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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template