Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tomkp/create.js

Shortcut for document.createElement
https://github.com/tomkp/create.js

Last synced: about 1 month ago
JSON representation

Shortcut for document.createElement

Awesome Lists containing this project

README

        

# create.js

A shortcut for document.createElement in only 739 bytes.

[![Build Status](https://travis-ci.org/tomkp/create.js.png)](https://travis-ci.org/tomkp/create.js)

## examples:

```javascript

var span = Create.element({tag: 'span', contents: 'Some text', attributes: {id: 'abc', class: 'xyz'}, events: {click: function() {} }});

// is just a shortcut for:

var element = document.createElement('span');
element.appendChild(document.createTextNode('Some text'));
element.setAttribute('id', 'abc');
element.setAttribute('class', 'xyz');
element.addEventListener('click', function() {});

```