Reputation: 71
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);
});
Upvotes: 7
Views: 12475
Reputation: 5249
You can use fadeToggle()
$('.info').click(function() {
$('h7').fadeToggle(750);
}
Upvotes: 24