勾选后背景变色的样式:

<html>
<head>
<script>
function chaCloor(field){
var pig = field.checked;
pig?field.nextSibling.style.backgroundColor="yellow":field.nextSibling.style.backgroundColor="#fff";
}
</script>
<style>
.checkbox {
background-Color:expression(this.checked?'yellow':'buttonface');
}
</style>
</head>

<body >
<div>
<input type="checkbox" onClick="chaCloor(this)"><span>选项1</span>
<input type="checkbox" onClick="chaCloor(this)"><span>选项2</span>
<input type="checkbox" class="checkbox">
<input type="checkbox" class="checkbox">
</div>
</body>

</html>

预览效果


文章来源: 本站原创 引用(0) 阅读(62)
 
对《细节看体验(1)》有 0 条评论
发表评论
昵称

网址

电邮
打开HTML 打开UBB 表情 打开表情 隐藏 记住我 [注册]