On Jan 10, 2008, at 1:03 AM, s.ross wrote:
This is probably one of those asked-and-answered questions, but I
didn't turn it up in a Google search, doc search, or search of this
group. Here it is: I want to click a link to slide a div down and the
next click slide it back up. Toggle with an effect. Because I am not
triggering the effect off a click on the element whose visibility I
want to toggle, the Event.Toggle method doesn't seem to fit. Here's
the point I've reached, which doesn't quite work. I'm sure there is a
really easy way to do this but I'm not seeing it.
$('a#image').click(function(){
$('#image-drawer')
.filter(':hidden')
.slideDown()
.end()
.filter(':visible')
.slideUp()
;
return false;
});
Thanks,
--s
Hi S,
In your code, it looks like you're first sliding the #image-drawer
element down, and then sliding it back up. I think a
simple .slideToggle() would work fine in this situation:
$('#image').click(function() {
$('#image-drawer').slideToggle();
});
Hope that helps.
--Karl
_________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com