标签:
直接上代码:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<script>
function onClickHander(obj){
if(obj.checked){
console.log("selected");
}else{
console.log("unselected");
}
}
</script>
<body>
<input id="checkBox" type="checkbox" onclick="onClickHander(this)"></input>
</body>
</html>
1、绑定事件时记得加上this,把节点对象传入;
2、利用节点的checked属性,可判断当前是否已选中。
就是这样~
愉快的周五 : )
标签:
原文地址:http://www.cnblogs.com/Being-a-runner-up/p/5633834.html