Matt wrote:
Hi everyone,

I'm very new to jQuery and am trying to have a div toggle between
hidden and shown using the slideToggle function. This is my code that
I have in the head of my html:

$(document).ready(function(){
        $('a#link').click(
                $('div#bugDiv').slideToggle('slow')
                );

});

The link that I want to associate the onClick to has an id of "link"
and the div has an id of "bugDiv".

Right now, the way it works, the bugdiv slides to hidden on load, as
though it's just executing the code as opposed to associating it as
the onclick action..

Any help would be appreciated! Thanks in advance,
Matt

Hi Matt
I think the click handler will need wrapping in a function as well:

$('a#link').click(function() {
        $('div#bugDiv').slideToggle('slow');
        return false;
});

I've also added return false as Mike suggested which will stop the link's default action from being followed.


Regards,
Michael Price

Reply via email to