例子:
当 checkBox 改变时,执行方法打印输出
<!DOCTYPE html>
<html>
<head>
<title>监听 checkBox </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>