The example in this article describes how to use js to change the text color of the selected check box. Share it with everyone for your reference. The details are as follows:
Here, when the check box is selected, the text is added with a background color. It is still very useful to change it.
The operation effect is as shown below:
The online demo address is as follows:
http://demo.jb51.net/js/2015/js-checkbox-cha-font-color-codes/
The specific code is as follows:
<html> <head> <title>选中复选框文字变色</title> <style> .checkbox { background-Color:e-xpression(this.checked?'yellow':'buttonface'); } </style> </head> <script> function chaCloor(field){ var pig = field.checked; pig?field.nextSibling.style.backgroundColor="skyblue":field.nextSibling.style.backgroundColor="white"; } </script> <body> <table height=48 width=136> <tr> <td><input type="checkbox" onClick="chaCloor(this)"><span>网页特效</span></td> </tr> <tr> <td><input type="checkbox" onClick="chaCloor(this)"><span>源码下载</span></td> </tr> <tr> <td><input type="checkbox" onClick="chaCloor(this)"><span>编程软件</span></td> </tr> </table> </body> </html>
I hope this article will be helpful to everyone’s JavaScript programming design.