jQuery实现CheckBox全选、全不选

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
<title>jQuery实现CheckBox全选、全不选</title> 
<script src="http://code.jquery.com/jquery-1.4.4.min.js" type="text/javascript"></script>    <script type="text/javascript"> 
         $(function() { 
            $("#checkAll").click(function() { 
                $('input[name="subBox"]').attr("checked",this.checked);  
            }); 
            var $subBox = $("input[name='subBox']"); 
            $subBox.click(function(){ 
                $("#checkAll").attr("checked",$subBox.length == $("input[name='subBox']:checked").length ? true : false); 
            }); 
        }); 
</script> 
</head> 
<body> 
   <div> 
      <input id="checkAll" type="checkbox" />全选 
      <input name="subBox" type="checkbox" />项1 
      <input name="subBox" type="checkbox" />项2
      <input name="subBox" type="checkbox" />项3 
      <input name="subBox" type="checkbox" />项4 
   </div> 
</body> 
</html>

创新互联坚持“要么做到,要么别承诺”的工作理念,服务领域包括:网站设计制作、成都网站制作、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的兴平网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!

文章名称:jQuery实现CheckBox全选、全不选
标题URL:https://www.cdcxhl.com/article2/poeeoc.html

成都网站建设公司_创新互联,为您提供自适应网站品牌网站建设App开发电子商务小程序开发品牌网站制作

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都app开发公司