我有:
<label class="checkbox-container" for="terms">I agree
with the Terms and Conditions</label>
<input class="checkbox required" id="terms" name="terms" type="checkbox">
当调用输入上的错误类时,我希望标签的:: before颜色更改为红色。实时预览结帐:http : //apespark.com/formifyPro/examples/register.html
我不知道如何在CSS中指定它并设计这种特定的案例方案。
你是这个意思吗?-的jsfiddle
如果未选中该复选框,则可以使用一些Javascript将标签的样式更改为红色,我认为这是您想要的,如下所示:
的HTML:
<label class="checkbox-container" for="terms" id="termText">I agree
with the Terms and Conditions</label>
<input class="checkbox required" id="terms" name="terms" type="checkbox">
<button id="click1">
Submit
</button>
javascript:
document.getElementById("click1").onclick = function checkTerms(){
if((document.getElementById("terms")).checked){
} else{
document.getElementById("termText").style.color = "red";
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句