首页 > 其他 > 详细

checkBox的使用和事件监听

时间:2016-07-01 17:57:47      阅读:169      评论:0      收藏:0      [点我收藏+]

直接上代码:

<!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属性,可判断当前是否已选中。

就是这样~

愉快的周五 : )

checkBox的使用和事件监听

原文:http://www.cnblogs.com/Being-a-runner-up/p/5633834.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!