O'Reilly logo

YUI 2.8 Learning the Library by Dan Wellman, Daniel Barreiro

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using Animation to create an Accordion Widget

We can put the Animation Utility to good use to create a simple, yet visually appealing, Accordion-style content area. Using our standard template for the examples, we'll make sure to include the inevitable yahoo-dom-events.js and, for this example, animation-min.js and, in the <body>, the following HTML:

<div id="accordion">
<h1>Section 1</h1>
<div>
<p>Lorem ipsum dolor … Sed dictum.</p>
</div>
<h1>Section 2</h1>
<div>
<p>Lorem ipsum dolor … Sed dictum.</p>
<p>Lorem ipsum dolor … Sed dictum.</p>
</div>
<h1>Section 3</h1>
<div>
<p>Lorem ipsum dolor … Sed dictum.</p>
<p>Lorem ipsum dolor … Sed dictum.</p>
<p>Lorem ipsum dolor … Sed dictum.</p>
</div>
</div>

The content of each paragraph is that long ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required