html - 标题出现在悬停输入文本时

标签 html css

我正在尝试使输入文本具有标题选项,就像您可以使用 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>

我还有一个关于这个标签的问题:如果你想在文本框中输入一些东西你不能,因为复选框会被选中......你能告诉我为什么会这样吗?

http://jsfiddle.net/2xw32q80/

最佳答案

在 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/

相关文章:

javascript - 使用 jQuery 切换大量页面项目很慢

html - bulma:水平表单控件未正确展开

html - 当页面为全尺寸时 div 具有 100% 宽度,但当页面尺寸减小时宽度减小

javascript - 区分文本和跨度

css - IE 7/8/9 上的奇怪 CSS 问题

css - 如何在反向运动中保持图像旋转?

css - 像 *+* 这样的选择器可以安全使用吗?

javascript - jQuery get json each 是堆叠字符串而不是追加

javascript - 带有javascript的单选按钮样式

html - Bootstrap 导航栏切换器