What is the jQuery destructive method end()?


The jQuery end() method reverts the most recent destructive operation, changing the set of matched elements to its previous state right before the destructive operation.

This is how you can use it,

operations.end()

Example

You can try to run the following code to learn about jQuery destructive method end(),

Live Demo

<html>
   <head>
      <title>jQuery end() function</title>
      <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
       
      <script>
         $(document).ready(function(){
            $("p").find("span").end().css("border", "4px red solid");
         });
      </script>
       
      <style>
         p{
            margin:5px;
            padding:5px;
         }
      </style>
   </head>
   
   <body>
      <p><span>Hello</span> World!</p>
   </body>
   
</html>

Updated on: 09-Dec-2019

180 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements