Created
September 14, 2011 13:14
-
-
Save beoran/1216512 to your computer and use it in GitHub Desktop.
Dynamic object generation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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