Skip to content

Instantly share code, notes, and snippets.

@beoran
Created September 14, 2011 13:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beoran/1216512 to your computer and use it in GitHub Desktop.
Save beoran/1216512 to your computer and use it in GitHub Desktop.
Dynamic object generation
function $id(id) {
return document.getElementById(id)
}
function $create(kind) {
return document.createElement(kind)
}
function $move(node, x, y) {
node.style.left = x.toString() + 'px'
node.style.top = y.toString() + 'px'
}
/** uses $create to create a new document node of kind kind, and appends it to
the parent. */
function $spawn(parent, kind) {
var child = $create(kind)
parent.appendChild(child)
return child
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment