Chinaunix首页 | 论坛 | 博客
  • 博客访问: 931415
  • 博文数量: 210
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 2070
  • 用 户 组: 普通用户
  • 注册时间: 2014-11-19 21:54
文章分类

全部博文(210)

文章存档

2020年(2)

2019年(18)

2018年(27)

2017年(5)

2016年(53)

2015年(88)

2014年(17)

分类: jQuery

2016-09-06 21:25:57


代码如下:
html:

点击(此处)折叠或打开

  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <meta charset="utf-8" />
  5.         <title></title>
  6.         <link rel="stylesheet" type="text/css" href="css/1.css"/>
  7.         <script type="text/javascript" src="js/jquery-1.9.1.js"></script>
  8.         <script type="text/javascript" src="js/1.js"></script>
  9.     </head>
  10.     <body>
  11.         <label for="">你好:</label>
  12.         <input type="checkbox" /><span>全选</span><br/>
  13.         <label for="">有户:</label>
  14.         <input type="checkbox" /><br/>
  15.         <label for="">密码:</label>
  16.         <input type="checkbox" /><br/>
  17.         <label for="">爱好:<label>
  18.         <input type="checkbox" /><br/>
  19.         <label for="">啦啦: </label>
  20.         <input type="checkbox" /><br/>
  21.         
  22.         

  23.     </body>
  24. </html>

js:

点击(此处)折叠或打开

  1. indow.onload = function(){
  2.     
  3.     $(function(){
  4.         
  5.         
  6.         //获取所有的input
  7.         $("input :first").click(function(){
  8.         //this指向input第一个元素
  9.          if($("this").prop("checked")){
  10.                 $("input").prop("checked",false);
  11.             }else{
  12.                 $("input").prop("checked",true);
  13.                 
  14.             }
  15.             
  16.             
  17.         })
  18.         
  19.         
  20.    
  21.     })
  22.     
  23.  
  24.     
  25.     
  26. }


阅读(609) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~