我正在尝试使输入文本具有标题选项,就像您可以使用 div 所做的那样...可以这样做吗?
这个我试过了,好像不行。。。 HTML:
<label>
<input type="checkbox" class="promote_checkbox">Promote with</input>
<input type="text" class="promote_points_number" maxLength="3" title="you need minimum 5 points to promote">Points</input>
</label>
我还有一个关于这个标签的问题:如果你想在文本框中输入一些东西你不能,因为复选框会被选中......你能告诉我为什么会这样吗?
最佳答案
在 HTML 中,<input>
标签没有结束标签,而在 XHTML 中它必须正确关闭,像这样 <input />
.
<label>
标签定义 <input>
的标签元素,所以你需要包装每个 <input>
用自己的<label>
像这样的标签:
<label>Label for checkbox
<input type="checkbox" class="promote_checkbox">
</label>
<label>Label for points
<input type="text" class="promote_points_number" maxLength="3" title="you need minimum 5 points to promote">
</label>
或者有一个 for
每个 <label>
的属性对应于 id
其属性 <input>
<label for="box">Label for checkbox</label>
<input type="checkbox" id="box"><br>
<label for="points">Label for points</label>
<input type="text" id="points" maxLength="3" title="you need minimum 5 points to promote">
关于html - 标题出现在悬停输入文本时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28364365/