Skip to content

Instantly share code, notes, and snippets.

@fitzgen
Created March 6, 2010 07:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fitzgen/323570 to your computer and use it in GitHub Desktop.
Save fitzgen/323570 to your computer and use it in GitHub Desktop.
div = function () {
var args = Array.prototype.slice.call(arguments, 0);
var attrs = {};
var txt = args.map(function (arg) {
if (typeof arg === "string") {
return arg;
} else {
for (attr in arg) {
attrs[attr] = arg[attr];
}
}
return "";
}).join(" ");
return "<div " + (function () {
var str = "";
for (x in attrs) {
str = str + x + ("=\"" + attrs[x] + "\" ");
}
return str;
}()) + ">" + txt + "</div>";}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment