首页 > 其他 > 详细

监听页面上的checkbox是否选中

时间:2016-12-05 13:49:01      阅读:176      评论:0      收藏:0      [点我收藏+]

第一种

<!DOCTYPE html>
<html>
<head>
    <meta charset=UTF-8>
    <title>checked</title>
    <script type="text/javascript" src=http://cdn.bootcss.com/jquery/1.11.2/jquery.min.js></script>
</head>
<body>
<form>
<input  type=checkbox >
<input  type=checkbox >
<input  type=checkbox >
<input type=checkbox >
<input type=checkbox >
    </form>
</body>
<script type="text/javascript">
    $(":checkbox").on("change",function(){
        var $checkbox = $(this);
        console.log($(input:checked).length);
    });
</script>
</html>

可以实时监听页面上有几个checkbox的值是checked

 

监听页面上的checkbox是否选中

原文:http://www.cnblogs.com/lwwen/p/6133389.html

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