
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference Between jQuery show and jQuery hide
jQuery show() method
The show( speed, [callback] ) method shows all matched elements using a graceful animation and firing an optional callback after completion.
Here is the description of all the parameters used by this method −
- speed − A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
- callback − This is optional parameter representing a function to call once the animation is complete.
Example
You can try to run the following code to learn how to work with show() method:
<html> <head> <title>The jQuery Example</title> <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function() { $("#show").click(function () { $(".mydiv").show( 100 ); }); $("#hide").click(function () { $(".mydiv").hide( 100 ); }); }); </script> <style> .mydiv { margin:10px; padding:12px; border:2px solid #666; width:100px; height:100px; } </style> </head> <body> <div class = "mydiv"> This is a SQUARE. </div> <input id = "hide" type = "button" value = "Hide" /> <input id = "show" type = "button" value = "Show" /> </body> </html>
jQuery hide() method
The hide( speed, [callback] ) method hides all matched elements using a graceful animation and firing an optional callback after completion.
Here is the description of all the parameters used by this method −
speed − A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
callback − This is optional parameter representing a function to call once the animation is complete.
Example
You can try to run the following code to learn how to work with hide() method:
<html> <head> <title>The jQuery Example</title> <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function() { $("#show").click(function () { $(".mydiv").show( 200 ); }); $("#hide").click(function () { $(".mydiv").hide( 200 ); }); }); </script> <style> .mydiv { margin:20px; padding:20px; border:4px solid #666; width:100px; height:100px; } </style> </head> <body> <div class = "mydiv"> This is a SQUARE. </div> <input id = "hide" type = "button" value = "Hide" /> <input id = "show" type = "button" value = "Show" /> </body> </html>