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 new instances of the plugin


Imagine that you'd like several instances of the ImageCaption class. We'll create a situation where one of the images will have its caption at the top of the image instead of before.

  1. First, modify the HTML markup in such a way that the last image has an ID of #caption-on-top.

    <body>
    <h1>ImageCaption Script</h1>
    <p><img src="lake_mead.jpg" width="300" height="201" alt="Lake mead in a speeding car." /></p>
    <p><img src="clouds.jpg" width="150" height="101" /></p>
    <p><img id="caption-on-top" src="red_rocks.jpg" width="300" height="201" title="A photo of Red Rock Mountain near Las Vegas, Nevada." /></p>
    </body>
    
  2. Next, let's create a class instance of the ImageCaption class. This time, we limit the image caption to only the image with the ID of #caption-on-top. Also, we use one of our options, captionPosition, to change the default value of'after' to'before'.

    var captionOnTop...