Supported: Internet Explorer 6+ Supported: Mozilla Firefox 2+ Supported: Apple Safari 3+ Supported: Google Chrome Supported: Opera 9+ Supported: Konqueror

Element Class

Element

This class helps creating DOM elements in a simple way. Element constructor takes 2 argumens: tagName and attributes definition:

Element( tagName [, attributes])

Attributes argument is optional. When it’s passed it should be defined as JavaScript object, like: { attrName : attrValue, …}. Seee example below to understand the principals of working with Element class.

<div id="box"></div>
...
$('box').appendChild(
  new Element(
    'input',
    {
      type : 'button',
      value : 'Click me',
      onclick : 'alert( "Woohoo, I'm clicked!")'
    })
);