Scriptaculous’s Effect.Morph can take a CSS class and apply it over a period of time. I have a div which expands when a button is clicked, so it uses Effect.Morph to apply an .expanded class.
Now I’d like to remove the .expanded class on a second click, toggling the div closed again. How can I invoke Effect.Morph to do that?
The documentation says this about Effect.Morph:
So you would need to call it again, specifying the initial CSS properties so your div can revert back to its initial state, for example (again, from the docs):
Alternatively, you could use Prototype to remove the class altogether:
Scriptaculous depends on Prototype.js, in case you weren’t aware, so the second option is a viable one.
Finally, you can set the style to nothing (I think):