tags:

views:

130

answers:

3

Hi,

I know how to show/hide, or fadeIn/out in jquery, but is there a built in way to toggle between show/hide or fadein/out or do I have first look if the element is display:none, if yes then show otherwise hide?

+13  A: 

You could possibly use the toggle() function.

http://docs.jquery.com/Effects/toggle

or

http://docs.jquery.com/Effects/slideToggle

John Boker
And for regular show/hide: http://docs.jquery.com/Effects/toggle
Stuart Branham
A: 
$(element).toggle()

Toggle displaying each of the set of matched elements. If they are shown, toggle makes them hidden (using the hide method). If they are hidden, toggle makes them shown (using the show method).

http://docs.jquery.com/Effects/toggle

Julien
A: 

Check out the cycle plugin, it's great. Might not be exactly what you're looking for but it has some very nice features.

http://www.malsup.com/jquery/cycle/

nizmow