jQuery show() Method
You are Here:
jQuery show() Method
The jQuery show()
method displays the matched elements.
Example
HTML Editor
<!DOCTYPE html>
<html lang="en-US">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<h1>jQuery show() Method</h1>
<button id="myHide">Hide</button>
<button id="myShow">Show</button>
<script>
$(document).ready(function(){
$("#myHide").click(function(){
$("p").hide();
});
$("#myShow").click(function(){
$("p").show();
});
});
</script>
</body>
</html>
Syntax
$(selector).show(speed, easing, callback);
Parameter Values
Value | Type | Explanation |
---|---|---|
speed | Optional | Specifies the speed of the show effect. Default value is 400 milliseconds. Possible values are
|
easing | Optional | Specifies the easing function to use for the transition. Default value is "swing" Possible values are
|
callback | Optional | Specifies a function to be called once the show() medthod is completed. |
show() with Speed
In the following example, we will specify the speed of the show effect to 2000ms (2 seconds).
Example
HTML Editor
<!DOCTYPE html>
<html lang="en-US">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<h1>jQuery show() Method</h1>
<button id="myHide">Hide</button>
<button id="myShow">Show</button>
<script>
$(document).ready(function(){
$("#myHide").click(function(){
$("p").hide();
});
$("#myShow").click(function(){
$("p").show(2000);
});
});
</script>
</body>
</html>
show() with Easing
In the following example, we will specify the easing function for show()
method to linear.
Example
HTML Editor
<!DOCTYPE html>
<html lang="en-US">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<h1>jQuery show() Method</h1>
<button id="myHide">Hide</button>
<button id="myShow">Show</button>
<script>
$(document).ready(function(){
$("#myHide").click(function(){
$("p").hide();
});
$("#myShow").click(function(){
$("p").show(2000, "linear");
});
});
</script>
</body>
</html>
show() with Callback
In the following example, we will call a function (myFunction) once the show effect is finished.
Example
HTML Editor
<!DOCTYPE html>
<html lang="en-US">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<h1>jQuery show() Method</h1>
<button id="myHide">Hide</button>
<button id="myShow">Show</button>
<script>
$(document).ready(function(){
$("#myHide").click(function(){
$("p").hide();
});
$("#myShow").click(function(){
$("p").show(2000, "linear", function(){
alert("show() method completed");
});
});
});
</script>
</body>
</html>
Reminder
Hi Developers, we almost covered 99.5% of jQuery Tutorials with examples for quick and easy learning.
We are working to cover every Single Concept in jQuery.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.