The hide() is an inbuilt method in jQuery used to hide the selected element.
Syntax:
$(selector).hide(duration, easing, call_function);
Here selector is the selected element.
Parameter: It accepts three parameters which are specified below-
- duration: It specifies the speed of the hide effect.
- easing: It specifies the speed of the element at different point of animation.
- call_function: This is call back function to be executed after hide operation.
Return Value: It does not return any value.
Code #1:
In the below code, no parameter is used to pass to this method.
<html> <head> </script> <!-- jQuery code to show the working of this method --> <script> $(document).ready(function() { $(".b1").click(function() { $("p").hide(); }); }); </script> <style> div { width: 50%; height: 80px; padding: 20px; margin: 10px; border: 2px solid green; font-size: 30px; } .b1 { margin: 10px; } </style> </head> <body> <div> <p>GeeksforGeeks !.</p> </div> <!-- click on this button and above paragraph will disappear --> <button class="b1">Click me !</button> </body> </html> |
Output:
Before clicking on “Click me!” button-

After clicking on “Click me!” button-

Code #2:
In the below code, parameter is passed to this method.
<html> <head> <script </script> <script> <!-- jQuery code to show the working of this method --> $(document).ready(function() { $(".btn1").click(function() { $("p").hide(1000, function() { alert("Hide() method has finished its working!"); }); }); }); </script> <style> p { width: 40%; padding: 20px; height: 50px; border: 2px solid green; } </style> </head> <body> <p>GeeksforGeeks.!</p> <!-- click on this button and above paragraph will hide --> <button class="btn1">Click to Hide</button> </body> </html> |
Output:
Before clicking on the “Click to Hide” button-

After clicking on the “Click to Hide” button-

Recommended Posts:
- jQuery | Hide/Show, Toggle and Fading methods with Examples
- How to hide a div when the user clicks outside of it using jQuery?
- How to hide div element after few seconds in jQuery ?
- How to Display/Hide functions using aria-hidden attribute in jQuery ?
- How to Hide an HTML Element in Mobile View using jQuery ?
- How to show/hide div element depending multiple values using Bootstrap and jQuery ?
- Show and hide password using JavaScript
- Hide or show elements in HTML using display property
- Hide the cursor in a webpage using CSS and JavaScript
- How to hide span element if anchor href attribute is empty using JavaScript ?
- Hide or show HTML elements using visibility property in JavaScript
- How to hide Bootstrap modal with JavaScript?
- How to display icon next to show/hide text on button?
- p5.js | hide() Function
- How to Show and Hide div elements using radio buttons?
- How to Show and Hide div elements using Checkboxes ?
- How to hide div element by default and show it on click using JavaScript and Bootstrap ?
- How to Hide an HTML Element by Class using JavaScript ?
- How to hide scroll bar for inactivity?
- How to hide âImage not foundâ icon when source image is not found?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


