I am currently using this code to try and use a button with a class of .info
as a toggle for fading in and fading out text. Right now the animation is running back to back with this code. Is there a way where I click the button once and have the text fade in without it fading out seconds later? The same will apply for fading out when you click the button again.
$('.info').click(function() {
$('h7').fadeIn(750);
});
$('.info').click(function() {
$('h7').fadeOut(750);
});
The fadeToggle() method toggles between the fadeIn() and fadeOut() methods. If the elements are faded out, fadeToggle() will fade them in.
The jQuery fadeOut() method is used to fade out a visible element. Syntax: $(selector).fadeOut(speed,callback); The optional speed parameter specifies the duration of the effect.
jQuery fadeToggle() If the elements are faded in, it will make them faded out and if they are faded out it will make them faded in. Syntax: $(selector). fadeToggle();
Main difference between FadeIn, FadeOut vs hide, Show is When you use FadeIn and fadeout Its remove line Slowly Like Opacity will 100 to 0 in a few mili-second but On other hand hide, Show will remove the line immediately Without wasting any mili-second.
You can use fadeToggle()
$('.info').click(function() {
$('h7').fadeToggle(750);
}
$('info').click(function(){
$('h7').fadeToggle(750);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With