惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

云风的 BLOG
云风的 BLOG
有赞技术团队
有赞技术团队
Simon Willison's Weblog
Simon Willison's Weblog
人人都是产品经理
人人都是产品经理
L
LINUX DO - 最新话题
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
A
Arctic Wolf
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
小众软件
小众软件
Jina AI
Jina AI
The Cloudflare Blog
P
Palo Alto Networks Blog
AWS News Blog
AWS News Blog
阮一峰的网络日志
阮一峰的网络日志
C
Cybersecurity and Infrastructure Security Agency CISA
Know Your Adversary
Know Your Adversary
T
Threat Research - Cisco Blogs
L
Lohrmann on Cybersecurity
NISL@THU
NISL@THU
G
GRAHAM CLULEY
Project Zero
Project Zero
博客园_首页
博客园 - 三生石上(FineUI控件)
罗磊的独立博客
Spread Privacy
Spread Privacy
WordPress大学
WordPress大学
Hugging Face - Blog
Hugging Face - Blog
Latest news
Latest news
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Cisco Blogs
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tor Project blog
S
Securelist
V
Vulnerabilities – Threatpost
T
The Exploit Database - CXSecurity.com
C
CERT Recently Published Vulnerability Notes
IT之家
IT之家
Google DeepMind News
Google DeepMind News
爱范儿
爱范儿
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The Last Watchdog
The Last Watchdog
T
Tenable Blog
宝玉的分享
宝玉的分享
S
Secure Thoughts
P
Privacy & Cybersecurity Law Blog
量子位
大猫的无限游戏
大猫的无限游戏
J
Java Code Geeks
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Security Archives - TechRepublic
Security Archives - TechRepublic

博客园 - angushine

获得本机IP地址 设置eclipse文件默认的编码方式 Eclipse Helios的PermGen space错误的解决办法 取指定长度的字符串(双字节算2) - angushine - 博客园 截取指定长度字符串 Silverlight项目无法启动调试 增强 VSS 的文件共享安全性 兼容各个版本浏览器的设置最小宽度 动态分配一维数组 浏览器区别 封装log4net C#获得调用方法的名称和类名 MySQL绿色安装方法1 WebBrowser中调用加载页面的Javascript方法 定时更新内存和虚拟内存 多线程中更新组件 Request、Request.QueryString、Request.Form与Request.Params 反射调用静态方法 开始→运行→输入的命令集锦(转载)
jQuery全选/全消CheckBox以及JS回调一例
angushine · 2009-10-22 · via 博客园 - angushine

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  
<title>test</title>
  
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  
<script type="text/javascript" src="http://www.cnblogs.com/scripts/jquery/jquery.js"></script>
</head>
<body>
  
<form id="form1" runat="server">
  
<input type="checkbox" id="cbAll" name="cbAll" onclick="changeAll(this.checked, 'cb')"/><br />
  
<input type="checkbox" id="cb_1" name="cb" value="1,11" onclick="changeItem(this, 'cbAll')"/><br />
  
<input type="checkbox" id="cb_2" name="cb" value="2,22" onclick="changeItem(this, 'cbAll')"/><br />
  
<input type="checkbox" id="cb_3" name="cb" value="3" onclick="changeItem(this, 'cbAll')"/><br />
  
<input type="checkbox" id="cb_4" name="cb" value="4" onclick="changeItem(this, 'cbAll')"/><br />
  
  
<hr />
  
<input type="checkbox" id="chkAll" name="chkAll" onclick="changeAll(this.checked, 'chk')"/><br />
  
<input type="checkbox" id="chk_1" name="chk" value="a" onclick="changeItem(this, 'chkAll')"/><br />
  
<input type="checkbox" id="chk_2" name="chk" value="b" onclick="changeItem(this, 'chkAll')"/><br />
  
<input type="checkbox" id="chk_3" name="chk" value="c" onclick="changeItem(this, 'chkAll')"/><br />
  
<input type="checkbox" id="chk_4" name="chk" value="d" onclick="changeItem(this, 'chkAll')"/><br />
  
  
<input type="button" value="Get" onclick="getItems()" />
  
  
<script type="text/javascript">
    
// 全选/全取消
    function changeAll(value, itemname) {
      $(
"input[type='checkbox'][name='" + itemname + "']").each(function(i) {
        $(
this).attr("checked", value);
      });
    }
// 选中/取消单个
    function changeItem(obj, itemall) {
      
var value = obj.checked;
      
var name = obj.name;
      
if (!value) {
        $(
'#' + itemall).attr("checked", value);
      } 
else {
        
// 在这里可以用length和size()来比较
        var checked = ($("input[type='checkbox'][name='" + name + "']").length ==
          $(
"input[type='checkbox'][name='" + name + "']:checked").size());
        $(
'#' + itemall).attr("checked", checked);
      }
    }
    
    
function getItems() {
      
//alert($("input[type='checkbox']").length);
      $("input[type='checkbox'][name='cb']").each(function(i) {
        
if ($(this).attr("checked")) alert($(this).val());
      });
    }
  
</script>
  
  
<div style="height: 20px; border-style: dashed; border-width: 1px;">
  
</div>
  
  
<h1>回调函数</h1>
  
<script type="text/javascript">
    
function add(a, callback){
      
var b = callback;
      alert(a 
+ b);
    }
    
function negative(c) {
      
return (-c);
    }
  
</script>
  
<input type="Submit" name="Submit" value="Submit" onclick="add(4, negative(3));"/>
  
</form>
</body>
</html>