源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

js实现选中复选框文字变色的方法

  • 时间:2020-10-17 22:24 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:js实现选中复选框文字变色的方法
本文实例讲述了js实现选中复选框文字变色的方法。分享给大家供大家参考。具体如下: 这里实现选中复选框时,文字加上一个背景色,变通一下,还是很有用的。 运行效果如下图所示: [img]http://files.jb51.net/file_images/article/201508/201581493358720.jpg?201571493726[/img] 在线演示地址如下: [url=http://demo.jb51.net/js/2015/js-checkbox-cha-font-color-codes/]http://demo.jb51.net/js/2015/js-checkbox-cha-font-color-codes/[/url] 具体代码如下:
<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>

希望本文所述对大家的javascript程序设计有所帮助。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部