views:

2415

answers:

2

Hi,

The scriptaculous wiki has a demo (http://github.com/madrobby/scriptaculous/wikis/effect-slidedown) that shows the SlideDown effect in use. However I need to have the same link to slide down if a certain DIV is hidden and SlideUp if that DIV is showing.

How do I achieve this?

Thanks.

A: 

Wrap it in a function, call the function instead.

function slideMe(myDiv) {

 if(Element.visible(myDiv)) {
 //slide up

 }

 else {

 //slide down

 }
}
Diodeus
This is a perfectly valid way of doing this. Why vote it down? Voting down is for WRONG answers.
Diodeus
+6  A: 

Use Effect.toggle.

Effect.toggle('element_id', 'slide');
ceejayoz