Chapter 3. And on the 8th Day: Creating HTML Elements

Writing hypertext markup, HTML is like creating a house that guests will enjoy when they visit. But do guests not open and close doors? We also cook for our guests, creating items that were not previously there. In this chapter we will cook up some HTML elements in the following ways:

  • Creating new elements
  • Injecting new elements
  • Creating new form elements

Raw JavaScript contains methods for creating and injecting HTML elements. When we use those elements, the thought may occur that the syntax for these useful methods is not quite easy to remember. The syntax for creating elements in MooTools is quite easy to follow and even easier to memorize.

Creating a DIV with a border on it

Before injecting any ...

Get MooTools 1.3 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.