Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to use toggle() method in jQuery ?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 160
    Comment on it

    Welcome to findnerd, today we are going to discuss on toggle() method in jQuery.
    Firstly let know what use of toggle() method

    In the toggle() method, you can toggle between the hide() and show() methods in jQuery. So we can say that toggle() method used to show elements are hidden and hidden elements are shown:

    Syntax of toggle()

    $(selector).toggle();

    you can take reference of bellow example.

    <html>
    <head>
         <!--  here call the jquery library -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script>
    $(document).ready(function(){
        $("button").click(function(){
            $("p").toggle();// call show() method on button
        });
    });
    </script>
    </head>
    <body>
    
    <button>Toggle Button</button>
    <!-- here write paragrah and content on which you want use toggle() -->
    <p>This is a example of toggle </p>
    
    
    </body>
    </html>
    

 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: