Home > Web Front-end > JS Tutorial > body text

js method to realize the color change of selected check box text_javascript skills

WBOY
Release: 2016-05-16 15:45:09
Original
1524 people have browsed it

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&#63;'yellow':'buttonface');
}
</style>
</head>
<script>
function chaCloor(field){
var pig = field.checked;
pig&#63;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>

Copy after login

I hope this article will be helpful to everyone’s JavaScript programming design.

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template