I am trying to modify the DOM via javascript. I've been suggested to use jQuery like this
var options = $("<div>")
.append(
$("<ul>").append(
$("<li>")
.text("Resolution: ")
.append(
$("<select>")
.append($("<option>")
.attr("value", $(window).width()+"x"+$(window).height())
.text("Window"))
.append($("<option>").text("1024x768"))
.append($("<option>").text("1280x1024"))
)
)
);
But I find it clunky, especially considering that it increases the amount of code to write of at leat 40% compared to just write to an html string and then add it. Is this the right way of using jQuery, or is there a best practice for DOM manipulation of this sort?