当前位置:编程学习 > JS >>

jquery判断复选框选中代码

jquery判断复选框选中代码

<script language="网页特效">
var checkcount=0;
    $("[name='chooseo教程ne']").each(function(){
        if($(this).attr("checked")){
            checkcount++;
        }
    });

</script>

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<title> new document </title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <script language="javascript" src="jquery.js"></script>
<script language="javascript">
<!--
   $("document").ready(function(){
  
    $("#btn1").click(function(){
   
    $("[name='checkbox']").attr("checked",'true');//全选
 
    })
       $("#btn2").click(function(){
   
    $("[name='checkbox']").removeattr("checked");//取消全选
 
    })
    $("#btn3").click(function(){
   
    $("[name='checkbox']:even").attr("checked",'true');//选中所有奇数
 
    })
    $("#btn4").click(function(){
   
    $("[name='checkbox']").each(function(){
   
  
    if($(this).attr("checked"))
    {
     $(this).removeattr("checked");
   
    }
    else
    {
     $(this).attr("checked",'true');
   
    }
  
    })
 
    })
     $("#btn5").click(function(){
    var str="";
    $("[name='checkbox'][checked]").each(function(){
    str+=$(this).val()+""r"n";
    //alert($(this).val());
    })
   alert(str);
    })
   })
//-->
</script>
 
</head>

<body>
<form name="form1" method="post" action="">
   <input type="button" id="btn1" value="全选">
   <input type="button" id="btn2" value="取消全选">
   <br>
   <input type="checkbox" name="checkbox" value="checkbox1">
   checkbox1
   <input type="checkbox" name="checkbox" value="checkbox2">
   checkbox2
   <input type="checkbox" name="checkbox" value="checkbox3">
   checkbox3
 
checkbox8
</form>

</body>
</html>

补充:网页制作,jquery 
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,