Flagrate API documentation

Home ▲
constructor

flagrate.createElement

flagrate.createElement([tagName = "div"[, attribute]]) → flagrate.Element
new flagrate.Element

Creates an HTML element with tagName as the tag name, optionally with the given attributes.

Example

// The old way:
var a = document.createElement('a');
a.setAttribute('class', 'foo');
a.setAttribute('href', '/foo.html');
a.appendChild(document.createTextNode("Next page"));
x.appendChild(a);

// The new way:
var a = flagrate.createElement('a', { 'class': 'foo', href: '/foo.html' }).insert("Next page").insertTo(x);