I tried this:
$('<input class="inputName" type="text" />').appendTo($('body'))
but it turns out
&开发者_StackOverflow中文版lt;body><input class="inputName" type="text"></body>
Is there a way to creat the proper self-closing label?
What you are doing is in fact correct. Ensure your DOCTYPE is XHTML.
Edit: You don't have to worry about any of this since the code won't pass through validators anyway (validators do not execute javascript).
精彩评论