jQuery onclick toggle class

Total Post:10

Points:70
JQuery 
 729  View(s)
Ratings:
Rate this:

How do I use toogle in this code

<body>

<h1>Hello</h1>
<p>Hi</p>
<button>Toggle</button>
</body>
  1. Post:14

    Points:98
    Re: jQuery onclick toggle class

    You can use below code for toggle class:

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script>
    $(document).ready(function(){
        $("button").click(function(){
            $("p").toggle();
          //   $("h1").toggle();
        }); }); </script>


      Modified On Jun-18-2018 10:18:54 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!