Created
August 17, 2011 21:00
-
-
Save kellysutton/1152617 to your computer and use it in GitHub Desktop.
Use jQuery for element construction
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
var createMyWrappedInput = function (defaultValue) { | |
var wrapper = $("<div class='Wrapper'></div>"), | |
input = $('<input type="text" />'); | |
input.val(defaultValue); | |
wrapper.append(input); | |
return wrapper; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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).