On Jan 10, 2008, at 6:28 AM, Karl Swedberg wrote:

>
> 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

Thanks for the quick reply, Karl. That is, indeed what was happening,  
and a slideToggle(); does solve the problem. So for me, the remaining  
question is: Say I wanted something nonstandard -- say a color or font  
size change -- to happen on click, and then on the next click have the  
element revert. I'm trying to get a sense of the idiom involved with  
getting jQuery to make a click toggle a binary state on another element.

Thx,

--s

Reply via email to