jquery 完成checkbox 全选问题

来源:互联网 发布:淘宝轮播图片不清晰 编辑:程序博客网 时间:2024/05/16 09:42
<html>
  <head>
    <title>test1.html</title>
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <script type="text/javascript" src="jquery/jquery.min.js"></script>
 <script type="text/javascript">
 $(function() {
  $("#button_show").click(function() {
   $("#age").show();
  });
  
  $("#button_hide").click(function() {
   $("#age").hide();
  }); 
 });
 
 function selectAll(field) {
  $(":checkbox[name='empId']").attr("checked", field.checked);
 }
 </script>
  </head>
  <body>
   用户:<input type="text" id="username"><br>
   年龄:<input type="text" id="age"><br>
   <input type="button" value="显示" id="button_show">
   <input type="button" value="隐藏" id="button_hide">
   <input type="checkbox" name="empId" onclick="selectAll(this)"/>全选</br>
   <input type="checkbox" name="empId" /></br>
   <input type="checkbox" name="empId"/ ></br>
   <input type="checkbox" name="empId" /></br>
   <input type="checkbox" name="empId" /></br>
   <input type="checkbox" name="empId" /></br>
   <input type="checkbox" name="empId" /></br>
   <input type="checkbox" name="empId" /></br>
  </body>
</html>
原创粉丝点击