Hi. I have 3 btns which are simple anchor tags within an unordered list each have a respective id of t1 ,t2 and t3. I also have 3 similar btns that are hidden with css they have respective ids of t1-discover, t2-discover and t3-discover. What I am wanting to achieve is when, say, t1 is clicked after 5 seconds it fadesIn t1-discover and fadesOut t2-discover and t3discover, same for t2 & t3. Here's my attempt with jQuery:
$("#t1").click(function() {
$("#t2-discover").stop().fadeOut(10);
$("#t3-discover").stop().fadeOut(10);
// delay fadein of link
setTimeout(function() {
$('#t1-discover').fadeIn(2000);
}, 5000);
});
$("#t2").click(function() {
$("#t1-discover").stop().fadeOut(10);
$("#t3-discover").stop().fadeOut(10);
// delay fadein of link
setTimeout(function() {
$('#t2-discover').fadeIn(2000);
}, 5000);
});
$("#t3").click(function() {
$("#t1-discover").stop().fadeOut(10);
$("#t2-discover").stop().fadeOut(10);
// delay fadein of link
setTimeout(function() {
$('#t3-discover').fadeIn(2000);
}, 5000);
});
This kinda works, the delay and the fades are there but when one btn is clicked it doesn't cancel out the other 2 animations they fade in but stay there is there a way to say fadeIn but also cancel and reset the other 2 animations? I would also like to learn to do this more efficiently I'm sure this code is very amaterish but I am still learning! Hope this makes sense and thanks in advance.