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—writing the ImageCaption script


Before we start writing our MooTools plugin, we'll take an additional step; we're going to write a functional script that accomplishes the task we've set out to do, which is to automatically caption images in a web page using their alt (or title) property. Imagine auto-captioning 20 images (or more) in a web page without having to do much other work than assigning them an alt or title property? This reduces the amount of HTML we have to write, which in turn, reduces HTML clutter and file size.

  1. Start with some HTML by putting images in a web page. In this web page, place three image elements (encapsulating these image elements inside a p tag is optional). For the first image, include an alt property/value pair. For the second image, do not provide any alt or title property/value pairs. This will serve as a test case on how our script will work without an image caption. The third one will have a title property instead of an alt property.

    <h1...