How to use jQuery.toggle() method in jQuery?

jQueryWeb DevelopmentFront End Technology

The toggle() method toggles displaying each of the set of matched elements.


You can try to run the following code to learn how to work with jQuery.toggle() method:

Live Demo


      <title>jQuery toggle() method</title>
      <script src = ""></script>
         $(document).ready(function() {

               $(".target").toggle( );
         p {
             border:1px solid green;

      <p>Click on the following button:</p>
      <button id = "toggle"> Toggle </button>

      <div class = "target">
         <img src = "../images/jquery.jpg" alt = "jQuery" />
Updated on 12-Dec-2019 08:57:49