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

You can do this as well.

On Wed, Dec 17, 2008 at 3:26 AM, Matt <matt.neil...@gmail.com> wrote:

>
> Worked perfectly. Thanks Michael and Mike!!
>
> On Dec 16, 6:43 am, Michael Price <m...@edwardrobertson.co.uk> wrote:
> > 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