jQuery toggle() Method Last Updated : 30 Jun, 2023 Suggest changes Share Like Article Like Report The toggle() method is used to check the visibility of selected elements to toggle between hide() and show() for the selected elements. show() is run when the element is hidden. hide() is run when the element is visible. Syntax: $(selector).toggle(speed, easing, callback) Parameters: It has three optional parameters: speed: It is used to specify the speed of the toggle effect. It can be in terms of milliseconds, slow or fast. easing: It is used to specify the speed of the element at the different points of animation. callback: The function to be immediately called after the toggle effect. Below is the example to show the toggle() method: html <!DOCTYPE html> <html> <head> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"> </script> <script> $(document).ready(function() { $("button").click(function() { $("#gfg").toggle(); }); }); </script> <style> #gfg { color: green; border: 5px solid black; width: 200px; text-align: center; } </style> </style> </head> <body> <div id="gfg">GeeksforGeeks</div> <button>Click to hide() and show() the above div</button> </body> </html> Output: Before clicking on the button: After clicking on the button: After clicking on the button again: C Code_Mech Follow Article Tags : Web Technologies JQuery jQuery-Effects Explore jQuery Tutorial 8 min read Getting Started with jQuery 4 min read jQuery Introduction 7 min read jQuery Syntax 2 min read jQuery CDN 4 min read jQuery SelectorsJQuery Selectors 5 min read jQuery * Selector 1 min read jQuery #id Selector 1 min read jQuery .class Selector 1 min read jQuery EventsjQuery Events 4 min read jQuery bind() Method 2 min read jQuery blur() Method 1 min read jQuery change() Method 2 min read jQuery EffectsjQuery animate() Method 2 min read jQuery clearQueue() Method 2 min read jQuery delay() Method 2 min read jQuery HTML/CSSjQuery addClass() Method 2 min read jQuery after() Method 1 min read jQuery append() Method 2 min read jQuery TraversingjQuery | Traversing 4 min read jQuery add() method 1 min read jQuery addBack() Method 2 min read My Profile ${profileImgHtml} My Profile Edit Profile My Courses Join Community Transactions Logout Like