Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Toggle method

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 53
    Comment on it

    This method is used to show() and hide the content of selected elements. show() method is execute when selected element content is hide while hide() method is execute when selected element content is visible.

     The toggle() method toggles between hide() and show() for the selected elements.

    Note : Toggle method is work in between hide() and show() method.

    <!DOCTYPE html>
    <html>
    <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
    <script>
    $(document).ready(function(){
        $("button").click(function(){
            $("p").toggle();
        });
    });
    </script>
    </head>
    <body>
    
    <p>This is a First paragraph.</p>
    
    <button>Toggle</button>
    
    </body>
    </html>

    Output :When you click on the button ,if message is visible then on clicking the button that message will be hide and vice versa.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: