Skip to content

Instantly share code, notes, and snippets.

@kellysutton
Created August 17, 2011 21:00
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 kellysutton/1152617 to your computer and use it in GitHub Desktop.
Save kellysutton/1152617 to your computer and use it in GitHub Desktop.
Use jQuery for element construction
var createMyWrappedInput = function (defaultValue) {
var wrapper = $("<div class='Wrapper'></div>"),
input = $('<input type="text" />');
input.val(defaultValue);
wrapper.append(input);
return wrapper;
};
@danawoodman
Copy link

One other note: If you're finding yourself using lots of concatenation or appending, try using jQuery-tmpl which allows you to create HTML templates that you can populate with data (similar to Django templates).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment