Book Image

MooTools 1.2 Beginner's Guide

Book Image

MooTools 1.2 Beginner's Guide

Overview of this book

MooTools is a simple-to-use JavaScript library, ideal for people with basic JavaScript skills who want to elevate their web applications to a superior level. If you're a newcomer to MooTools looking to build dynamic, rich, and user-interactive web site applications this beginner's guide with its easy-to-follow step-by-step instructions is all you need to rapidly get to grips with MooTools.
Table of Contents (14 chapters)
MooTools 1.2 Beginner's Guide
Credits
About the Authors
About the Reviewer
Preface

Time for action—creating an accordion


Accordions are great for displaying a large amount of content in a compact manner, as well as establishing an engaging experience by allowing users to interact with your content. In this example, we're going to create an accordion area that displays information about a hypothetical development firm. We'll have accordion sections for work, services, clients, and contact.

  1. First things first: solid HTML. We have to make sure that our accordion has good markup so that when JavaScript and CSS are disabled, users can still access content. We contain our accordion inside a div that's intuitively called accordion. Then we have h2/div pairs for each section. The h2s will serve as the trigger for expanding a section later on; we give then a class of trigger. The content of each section is inside divs with a class of section.

    <body>
    <h1>Portfolio Site</h1>
    <div id="accordion">
    <h2 class="trigger">Work</h2>
    <div class="section...