码迷,mamicode.com
首页 > 其他好文 > 详细

监听页面上的checkbox是否选中

时间:2016-12-05 13:50:47      阅读:97      评论:0      收藏:0      [点我收藏+]

标签:code   text   http   color   change   char   div   oct   blog   

第一种

<!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是否选中

标签:code   text   http   color   change   char   div   oct   blog   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!