您的位置:首页 > Web前端 > JQuery

jquery关于复选框的全选

2011-07-14 11:23 302 查看
js代码 
<script type="text/javascript">
 $("document").ready(function() {
  $("#all").click(function() {
   $("[name='single']").attr("checked", this.checked);
  });
  $("[name='single']").click(function() {
   $("#all").attr("checked", this.checked);
  });
 });
</script>
<body>
  <table border="1">
   <tr>
    <td>
     全选
     <input type="checkbox" id="all">
    </td>
   </tr>
   <tr>
    <td>
     <input type="checkbox" id="single" name="single" value="single">
    </td>
   </tr>
   <tr>
    <td>
     <input type="checkbox" id="single" name="single" >
    </td>
   </tr>
   <tr>
    <td>
     <input type="checkbox" id="single" name="single" >
    </td>
   </tr>
   <tr>
    <td>
     <input type="checkbox" id="single" name="single" >
    </td>
   </tr>
   <tr>
    <td>
     <input type="checkbox" id="single" name="single" >
    </td>
   </tr>
   <tr>
    <td>
     <input type="checkbox" id="single" name="single">
    </td>
   </tr>
  </table>
 </body>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  jquery function border input