I’m just learning jQuery, figuring out what’s possible, finding my way around.
I’d like to have a div “slide out” like an accordion, but I don’t want to pay the cost of the jQuery UI download, and also I want to allow multiple divs to be open at the same time.
How does it work? How is the slide-out effect of the accordion done, inside jquery.ui.accordion.js? Is there a call I can make to .animate() to move a div from display:none to display:block ? (I read that animate works only with numeric properties.)
I’m learning all sorts of things. I used jQuery only – no UI, no UI Accordion, no UI Effects – and got the slide-down effect that I wanted. Not sure of the terminology for this visual effect. (I think that is half the challenge with jQuery – what do I call the various effects). I think maybe some people call this “toggle blinds”.
Click this to see the effect: http://jsbin.com/ogape
Here’s the html fragment
This is the jQuery code:
That slideOut() function is slightly simplified from what it actually does. It also swaps the + and – for the expander button in the actual code, which makes it a little more complicated:
You can see the full html/js code at the live demo link referenced above.
The key thing that I did not know, is that one can animate the height by calling animate with “toggle”.