almost 9 years ago
In many sites we have seen that when we click on some button it will make some div faded, this will happen with the help of fadeOut() method in jquery.
If we want some faded div or hidden div to get show, we can do that by using fadeIn() method .
fadeToggle method helps us if we want to fadeOut or fadeIn some div at the same time .
Syntax
Speed:- In this parameter, we provide a string which defines the duration for which the effect take place i.e slow,normal or fast .
Duration of effect is specified by an optional speed parameter and values: "slow", "fast", or milliseconds can be taken by it.
Below is the jquery code for using this method:-
$(document).ready(function(){
$("button").click(function(){
$("#part1").fadeToggle();
$("#part2").fadeToggle("slow");
$("#part3").fadeToggle(2000);
});
});
$(document).ready(function(){
$("button").click(function(){
$("#part1").fadeToggle();
$("#part2").fadeToggle("slow");
$("#part3").fadeToggle(2000);
});
});
Below is the html code:-
Below is the css for above code:-
#part1{
width:100px;
height:100px;
background-color:grey;
}
#part2{
width:100px;
height:100px;
background-color:red;
}
#part3{
width:100px;
height:100px;
background-color:blue;
}
#part1{
width:100px;
height:100px;
background-color:grey;
}
#part2{
width:100px;
height:100px;
background-color:red;
}
#part3{
width:100px;
height:100px;
background-color:blue;
}
Can you help out the community by solving one of the following Javascript problems?
Do activity (Answer, Blog) > Earn Rep Points > Improve Rank > Get more opportunities to work and get paid!
For more topics, questions and answers, please visit the Tech Q&A page.
0 Comment(s)