Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 将复选框替换为粗体标题_Html_Checkbox - Fatal编程技术网

Html 将复选框替换为粗体标题

Html 将复选框替换为粗体标题,html,checkbox,Html,Checkbox,我不确定我是否得到了正确的标题。但我的观点是: 我想替换标准的checkox,例如: Select <input type="checkbox" name="sel" /> 选择 使用witch,我可以点击文本(如上面代码中的“选择”),通过点击它,我可以选择“选择”属性,并将文本加粗。再次单击它将取消选择它并取消绑定文本。 A不希望显示复选框 想法?我想到了javascript,但不知道如何使用。使用标签节点 <label> Select <inpu

我不确定我是否得到了正确的标题。但我的观点是:

我想替换标准的checkox,例如:

Select <input type="checkbox" name="sel" />
选择
使用witch,我可以点击文本(如上面代码中的“选择”),通过点击它,我可以选择“选择”属性,并将文本加粗。再次单击它将取消选择它并取消绑定文本。 A不希望显示复选框


想法?我想到了javascript,但不知道如何使用。

使用标签节点

<label>
  Select 
  <input type="checkbox" hidden="true"
    onclick="parentNode.style.fontWeight=checked?'bold':'';" />
</label>

挑选

您可以使用css在chrome中定义文本

<style> 
input:before{content:attr(myTextAnno)}
input:checked{font-weight:bold;}
</style>
<input type="checkbox" myTextAnno="Select">

输入:在{content:attr(myTextAnno)}之前
输入:选中{font-weight:bold;}

您可以使用css在所有浏览器中定义文本

<style> 
input:before{content:'Select'}
input:checked{font-weight:bold;}
</style>
<input type="checkbox">

输入:在{content:'Select'}之前
输入:选中{font-weight:bold;}

谢谢!所以我现在可以在输入标记和选择工作中使用“隐藏”属性了!但是如何才能输入粗体文本,以便知道何时选择它?不知何故,Onclick事件?你能更具体一点吗?iv在顶部的我的答案中添加了Onclick,但这样每个复选框都会被标题为“选择”。Chrome解决方案不适合我(无论如何,它应该适用于所有浏览器)。