The show() Method in jQuery is used to display the hidden and selected elements.
Note: This method display the hidden elements which are using CSS display: none property. The elements are not visible whose visibility is hidden.
Syntax:
$(selector).show( speed, easing, callback )
Parameters:This method accepts three parameters as mentioned above and described below:
- Speed: It is an optional parameter and used to specify the speed of the fading effect. The default value of speed is 400 millisecond. The possible value of speed are:
- milliseconds
- “slow”
- “fast”
- Easing: It is an optional parameter and used to specify the speed of element to different points of animation. The default value of easing is “swing”. The possible value of easing are:
- callback: It is optional parameter. The callback function is executed after show() method is completed.
Below examples illustrate the show() method in jQuery:
Example 1: This example showing display: none content with given speed.
HTML
<!DOCTYPE html>
< html >
< head >
< title >
jQuery Effect show() Method
</ title >
< style >
#Outer {
border: 1px solid black;
padding-top: 40px;
height: 140px;
background: green;
display: none;
}
</ style >
< script src =
</ script >
</ head >
< body style = "text-align:center;" >
< div id = "Outer" >
< h1 style = "color:white;" >
GeeksForGeeks
</ h1 >
</ div >< br >
< button id = "btn" >
Show
</ button >
< script >
$(document).ready(function () {
$("#btn").click(function () {
$("#Outer").show(1000);
});
});
</ script >
</ body >
</ html >
|
Output:
Example 2: This example showing display: none content with swing easing value.
HTML
<!DOCTYPE html>
< html >
< head >
< title >
jQuery Effect show() Method
</ title >
< style >
#Outer {
border: 1px solid black;
padding-top: 40px;
height: 140px;
background: green;
display: none;
}
</ style >
< script src =
</ script >
</ head >
< body style = "text-align:center;" >
< div id = "Outer" >
< h1 style = "color:white;" >
GeeksForGeeks
</ h1 >
</ div >< br >
< button id = "btn" >
Show
</ button >
< script >
$(document).ready(function () {
$("#btn").click(function () {
$("#Outer").show("swing");
});
});
</ script >
</ body >
</ html >
|
Output:
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
18 Nov, 2022
Like Article
Save Article