- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the 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>
- Related Articles
- What is the difference between jQuery.animate() and jQuery.hide()?
- What is the difference between jQuery.hide() and jQuery.remove() methods in jQuery?
- What is Host, and what is the difference between Nutrients and Nutrition?
- What is the difference between Java and JavaScript?
- What is the difference between JavaScript and ECMAScript?
- What is the difference between JavaScript and C++?
- What is the difference between HTML tags and ?
- What is the difference between jQuery and JavaScript?
- What is the difference between jQuery.size() and jQuery.length?
- What is the difference between jQuery and AngularJS?
- What is the difference between = and: = assignment operators?
- What is the difference between time.clock() and time.time()?
- What is the difference between decodeURIComponent and decodeURI?
- What is the difference between == and === in JavaScript?
- What is the difference between session and cookies?
