Jump to content

Problem with jQuery slideToggle() method.


Recommended Posts

Hi Everyone: I am having trouble with the JQuery Slide Toggle() method. Please refer to the code at: http://www.w3schools.com/jquery/tryit.asp?filename=tryjquery_slide_toggle What I want is for the flip element to change colour when the panel slides down and to return to the original colour when the panel slides up. I realize that I probably need the following elements:

  • an If statement;
  • the :hidden or :visible selector;
  • and the jQuery css() method

But I cannot figure out the proper syntax. Can anyone tell me what I need to add to the code at http://www.w3schools.com/jquery/tryit.asp?filename=tryjquery_slide_toggle to get this to work? Thanks in advance for whatever advice you can provide. John

Link to comment
Share on other sites

Check the documentation here, you can pass a function that will run when the animation completes: http://api.jquery.com/slideToggle/ The function can change the color. You can also change the color before or after the call to slideToggle and it will change the color when the animation starts instead of when it completes.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...