I am trying to get the HTML of an element to use in a template.
I tried using jQuery to create the element and then grab the HTML, but that doesn't seem to do what I thought it would do.
I am able to get most of the HTML string from the new element, but the "checked" attribute doesn't seem to get saved.
I can manually build up the HTML, but I'd rather have a library helper to make sure I don't make any silly typos.
Here is what I am trying to do...
var checkBoxAuto = $("<input />", {
id: "idAuto"
, type : "checkbox"
, class: "answer"
, checked : true
});
//How do I get outter HTML from dynamically created checkbox
var checkBoxAutoText = $("<div />")
.append(checkBoxAuto)
.remove().html();
See http://jsfiddle.net/Kp8e5/28/ for more details...