简体   繁体   English

如何使用jQuery创建自动关闭标签?

[英]how to use jquery to creat self-closing label?

I tried this: 我尝试了这个:

$('<input class="inputName" type="text" />').appendTo($('body'))

but it turns out 但事实证明

<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. 确保您的DOCTYPE是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). 编辑:您不必为此担心,因为代码无论如何都不会通过验证程序(验证程序不会执行javascript)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM