六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 52|回复: 0

反选 并修改选中的数量

[复制链接]

升级  6%

15

主题

15

主题

15

主题

秀才

Rank: 2

积分
59
 楼主| 发表于 2013-2-7 15:14:26 | 显示全部楼层 |阅读模式
<script>  var j=0//全局使用  jQuery(function ($) {  //加载触发  $("input[@type='checkbox']").each(function() {  if($(this).attr("checked")) {  j++;  } else {  j--;  }  $("#count").html(""+j);  });  $("#count").html(""+j);  //反选  $("#otherCheck").click(function(){  j = 0;  $("input[@type='checkbox']").each(function() {  if($(this).attr("checked")) {  $(this).attr("checked",false);  } else {  $(this).attr("checked",true);  j++;  }  });  $("#count").html(""+j);  });  });  </script>
<span id="count"></span><input type="checkbox" /><input type="button" id="otherCheck" value="反选" />
如果只是反选
$("input[@type='checkbox']").each(function() {    $(this).attr("checked",!$(this).attr("checked"));  });
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表