并<选择>标签选择>
我可以在 HTML
例如:
<select tabindex="2" name="agegrp" id="agegrp" >
<div>
<option value="-1">No preference</option>
</div>
</select>
Can I have a <DIV>
within an HTML <SELECT>
tag?
e.g.:
<select tabindex="2" name="agegrp" id="agegrp" >
<div>
<option value="-1">No preference</option>
</div>
</select>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
从规范:
即有一个名为“ SELECT”,开始标记是必需的,结束标记是必需的。它的子元素可以是 OPTGROUP 元素和/或 OPTION 元素,并且必须至少有其中之一。
由于 DIV 不是 OPTGROUP 或 OPTION,所以答案是否。
From the specification:
i.e. There is an element called "SELECT", the start tag is required, the end tag is required. It's children can be OPTGROUP elements and/or OPTION elements and there must be at least one of them.
Since a DIV is not an OPTGROUP or an OPTION, the answer is no.
不,不。尼特。
No. Nope. Niet.
否,但您可能对
optgroup< /a>
元素。请注意,在您开始围绕它构建设计之前,它的外观在不同的浏览器中往往会存在很大差异。No, but you may be interested in the
optgroup
element. Be aware that its appearance tends to vary a lot across different browsers before you start building designs around it though.不,也没有理由这样做。
No. And there is no reason to.
虽然您可以生成任何您想要的疯狂 HTML,但不建议使用 DIV。通过引入 DIV 您试图解决的问题是什么?
也许您不知道 OPTGROUP 标记?
While you can generate any crazy HTML you want, that is not a recommended use of DIV. What is the problem you are trying to solve by introducing the DIV?
Perhaps you are unaware of the OPTGROUP tag?
正如每个人所说,没有必要在选择列表中执行 div。如果您需要单独移动表单 ID 中的列表元素,建议使用单选按钮。
As everyone has stated there would be no need to do a div within a select list. if you need to individually move list elements in a form id suggest using radio buttons.