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—selecting an element with the dollar function


Let's select the list item with an ID of listItem and then give it a red color using the .setStyle() MooTools method.

  1. Inside your window.addEvent('domready') method, use the following code:

    $('listItem').setStyle('color', 'red');
    
  2. Save the HTML document and view it on your web browser. You should see the third list item in red.

  3. Now let's select the entire unordered list (it has an ID of superList), then give it a black border (in hexadecimal, this is #000000). Place the following code, right below the line we wrote in step 1:

    $('superList').setStyle('border', '1px solid #000000');
    
  4. If you didn't close your HTML document, hit your browser's refresh button. You should now see something like this: