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

Writing unobtrusive JavaScript with MooTools


Unobtrusive JavaScript is a set of techniques and principles for writing code that's separated from your web page's structure.

It's best to learn about unobtrusive JavaScript by way of example.

An "obtrusive" JavaScript example

In this example, you'll see JavaScript code that works perfectly fine but doesn't adhere to unobtrusive JavaScript principles. The script contains a function called mouseClick() that, when triggered, opens up an alert dialog box with the message, You clicked me!.

The HTML markup is a simple unordered list of links. The hyperlinks<a> are assigned an onclick attribute which triggers the mouseClick() function when you click on them.

<html>
<head>
<script type="text/javascript">
// A simple function that opens an alert dialog box with a message
function mouseClick()
{
alert( 'You clicked me!' );
}
</script>
</head>
<body>
<ul id="nav">
<li><a onclick="javascript:mouseClick...