Skip to content

Instantly share code, notes, and snippets.

@viankakrisna
Created April 5, 2017 21:10
Show Gist options
  • Save viankakrisna/51650e7295ea3bb338a271ee3882f45e to your computer and use it in GitHub Desktop.
Save viankakrisna/51650e7295ea3bb338a271ee3882f45e to your computer and use it in GitHub Desktop.
function elt(name, attributes) {
var node = document.createElement(name);
if (attributes) {
for (var attr in attributes)
if (attributes.hasOwnProperty(attr))
node.setAttribute(attr, attributes[attr]);
}
for (var i = 2; i < arguments.length; i++) {
var child = arguments[i];
if (typeof child == "string")
child = document.createTextNode(child);
node.appendChild(child);
}
return node;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment