Skip to content

Instantly share code, notes, and snippets.

@benshimmin
Last active October 5, 2015 08:47
Show Gist options
  • Save benshimmin/2780772 to your computer and use it in GitHub Desktop.
Save benshimmin/2780772 to your computer and use it in GitHub Desktop.
One-liner to make DOM elements (like Backbone's; requires jQuery)
/* usage: var $el = make("div", {"class" : "foo"}, "bar"); // -> <div class="foo">bar</div> */
function make(t, a, c) { var e; return e = document.createElement(t), a && $(e).attr(a), c != null && $(e).html(c), e; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment