Home › Forums › JavaScript › Jquery – Toggle & Fade (noob here) › Re: Jquery – Toggle & Fade (noob here)
January 21, 2011 at 2:28 pm
#64791
Participant
Hi Vinnix,
Thank you for responding!
I did try that and it didn’t work. I got lucky and found someone else’s script that does the job:
$(function()
{
$('div#whois-question a').toggle(
function()
{
$('div#whois-question a').animate({
left: "590px"
}, 500);
},
function()
{
$('div#whois-question a').animate({
left: "0"
}, 500);
});
$('div#whois-question a').click(function() {
$('p#who-is').toggle(400, "swing");
$(this).toggleClass("active");
})
});
What I don’t understand is, why did they add function() before the animate? I originally tried this with toggle, but didn’t work:
$(function() {
$('div#whois-question a').toggle {
$('div#whois-question a').animate({ left: "590px" }, 500);
},
function() {
$('div#whois-question a').animate({ left: "0" }, 500);
});
});
Is there a reason you need a function before each animate?
– Steph