我被困在几行代码中,我无法解决我的问题,所以我要求您的帮助。根据复选框状态更改标签的颜色
我想根据复选框(法语和德语)的状态更改标签的颜色(id selectSubject)。
<div id="chooseSubject" style="margin-bottom:24px;">
<label id="selectSubject" class="form-control">Select your subject(s)</label>
<table style="width:auto;text-align:left;margin-bottom:1px;margin-top:13px" >
<tr>
<th style="font:inherit;padding-right:110px;"><input type="checkbox" id="french" style="display:none; position:absolute; left:9999px;"><label for="french"><span></span>French</label></th>
<th style="font:inherit;"><input type="checkbox" id="german" style="display:none; position:absolute; left:9999px;" class="1" value="1""><label for="german"><span></span>German</label></th>
</tr>
</table>
</div>
我看看到CSS的解决方案,但我不明白是怎么运营的工作,如<,>, - ,+,所以我没能解决我的问题。
所以只是为了澄清,如果没有选中复选框,selectSubject的颜色不会被改变,但是如果它们中的任何一个被选中,它就会变为颜色。
希望这些都有道理,非常感谢。
如果您只想使用css,当您的html以这种方式构建时,它不起作用。复选框必须位于标签之前。您可以使用javascript来检查状态并相应地设置标签。 – deadfishli
你的问题没有意义。你如何将'selectSubject'的颜色应用于标签? – ProEvilz
可能重复[突出标签,如果复选框被选中](http://stackoverflow.com/questions/5275857/highlight-label-if-checkbox-is-checked) –