Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Jquery – Toggle & Fade (noob here) Re: Jquery – Toggle & Fade (noob here)

#64791
StephBertha
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