Skip to content

Instantly share code, notes, and snippets.

@thejefflarson

thejefflarson/e.js

Created Feb 2, 2016
Embed
What would you like to do?
var e = function(/* tag, attrs, text, children...*/ ) {
var args = [].slice.call(arguments);
var tag = args.shift() || 'div';
var atts = args.shift() || attrs;
var text = args.shift() || '';
var kids = args;
var el = document.createElement(tag);
Object.keys(atts).forEach(function(k) {
el.setAttribute(k, atts[k]);
});
el.appendChild(document.createTextNode(text));
kids.forEach(function(e) {
el.appendChild(e);
});
return el;
};
el.appendChild(e('div', {id:'legend'}, 'Legend',
e('ul', {id: 'breaks'}, '',
e('li', {id:'break1'}),
e('li', {id:'break2'}),
e('li', {id:'break3'})
)
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment