Skip to content

Instantly share code, notes, and snippets.

@quinn
Created September 30, 2008 21:44
Show Gist options
  • Save quinn/13967 to your computer and use it in GitHub Desktop.
Save quinn/13967 to your computer and use it in GitHub Desktop.
// fun syntax for making elements on the page.
// from Aardvark Tools
jQuery.el= function(elem,properties) {
var i, s, p, c;
if (typeof(elem)=="string")
elem = document.createElement(elem);
if (properties) {
s = properties.style;
if (s)
for (i in s)
elem.style[i] = s[i];
for (i in properties) {
p = properties[i];
if (p != s)
elem[i] = p;
}
}
for (i=2; i<arguments.length; i++) {
c = arguments[i];
if (typeof(c) == "string")
c = document.createTextNode(c);
elem.appendChild(c);
}
return jQuery(elem);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment