开发者

jquery slideup/slidedown toggle

I have 2 classes: the helperopen and the helper. I'm writing a toggle that slides the helper div open or closed depending on its visibility. For the moment, it does the slideDown but it's not sliding up because the visibility condition test isn't working.

This is what I have so far:

$('.helperopen').click(function () {

   if( $('.helper').is('visible') == true )

   { $('.helper').slideUp(); }

 开发者_如何学C  else {
       $('.helper').slideDown();
       }

   });

Any suggestions are welcome.

Thanks.


I believe it should be:

if($('.helper').is(':visible') == true)


The JQuery API explains how you can use the slideToogle function, details of which can be found at http://api.jquery.com/slideToggle/

There is a great example half way donw the page that you can copy and paste to understand how it works.

For your example, try $('.helper').slideToggle("slow");

Here, the function will either show or hide the text in 600 milliseconds (the value of "Slow")

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜