码迷,mamicode.com
首页 > Web开发 > 详细

jquery版的全选,全不选和反选

时间:2016-12-27 13:28:55      阅读:211      评论:0      收藏:0      [点我收藏+]

标签:click   his   方法   jquer   button   att   set   on()   input   

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="js/jquery.js" type="text/javascript" charset="utf-8"></script>
<title></title>
</head>
<body>
<div id="content">
<p>
<input type="checkbox" name="" id="" value="" />打篮球
</p>
<p>
<input type="checkbox" name="" id="" value="" />打篮球
</p>
<p>
<input type="checkbox" name="" id="" value="" />打篮球
</p>
<p>
<input type="checkbox" name="" id="" value="" />打篮球
</p>
<p>
<input type="checkbox" name="" id="" value="" />打篮球
</p>
</div>
<input type="button" name="" id="quanxuan" value="全选" />
<input type="button" name="" id="buxuan" value="全不选" />
<input type="button" name="" id="fanxuan" value="反选" />
</body>
<script type="text/javascript">
$(function(){
$("#quanxuan").click(function(){
$(":checkbox").attr({"checked":true});//此方法不能使用太高jq版本
});
$("#buxuan").click(function(){
$(":checkbox").attr({"checked":false});
});
$("#fanxuan").click(function(){
$(":checkbox").each(function(){
//this.checked=!this.checked;
$(this).attr(‘checked‘,!$(this).attr(‘checked‘));
})
});
})
</script>
</html>

jquery版的全选,全不选和反选

标签:click   his   方法   jquer   button   att   set   on()   input   

原文地址:http://www.cnblogs.com/luoguixin/p/6225299.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!