checkbox全选
jquery代码如下(在jquery1.10.2下验证通过):
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script src="Scripts/WebForms/jquery-1.10.2.min.js"></script>
<title>测试全选</title>
<script type="text/ecmascript">
$(function () {
var tbl = $("#tblTest");
tbl.empty();
var tr = "";
for (var i = 0; i < 25; i++) {
var row = 1;
if (i % 5 == 0) {
tr += "<tr>";
}
tr += "<td style=\"padding:5px;\"><input type=\"checkbox\" id=\"" + i + "\" value=\"" + i + "\" /><label for=\"" + i + "\">第" + i+1 + "个</label></td>";
if ((i + 1) / 5 == row && (i + 1) % 5 == 0) {
tr += "</tr>";
row++;
}
}
tbl.append(tr); $("#chkAll").click(function () {
if ($("#chkAll").is(":checked")) {
$("#tblTest input[type='checkbox']").prop("checked", "checked");
}
else {
$("#tblTest input[type='checkbox']").removeAttr("checked");
}
});
});
</script>
</head>
<body>
<div style="margin-left: 5px;">
<div style="padding: 6px">
<input type="checkbox" id="chkAll" /><label for="chkAll">全选</label></div>
<div>
<table id="tblTest" style="width: 100%"></table>
</div>
</div>
</body>
</html>
checkbox全选的更多相关文章
- TreeView checkbox 全选
在使用TreeView 控件 ,进行权限管理的时候,需要使用 checkbox全选. 勾选父节点,子节点全部选中.取消父节点,子节点不选中. 勾选子节点,父节点也选中. 以下是在使用的例子: < ...
- JS checkbox 全选 全不选
/* JS checkbox 全选 全不选 Html中checkbox: <input type="checkbox" name="cbx" value= ...
- checkbox全选,反选,取消选择 jquery
checkbox全选,反选,取消选择 jquery. //checkbox全部选择 $(":checkbox[name='osfipin']").each(function(){ ...
- js初学—实现checkbox全选功能
布局如下: <p ><input type="checkbox" id="che1"/>全选</p><div id=& ...
- checkbox全选与反选
用原生js跟jquery实现checkbox全选反选的一个例子 原生js: <!DOCTYPE html> <html lang="en"> <hea ...
- angularjs实现 checkbox全选、反选的思考
之前做了一周的打酱油测试,其实感觉其实测试也是上辈子折翼的天使. 好长时间没写代码,感觉好多都不会了. 感谢这周没有单休,我能看熬夜看奥运了.我能有时间出去看个电影,我能有时间出去逛个商城,我能有时间 ...
- GridView CheckBox 全选
GridView CheckBox 全选 <script type="text/javascript"> $(function () { $("#allChe ...
- 利用jQuery实现CheckBox全选/全不选/反选
转自:http://www.cnblogs.com/linjiqin/p/3148259.html jQuery有些版本中实现CheckBox全选/全不选/反选会有bug,经测试jquery-1.3. ...
- jquery数组之存放checkbox全选值示例代码
使用jquery数组可以存放checkbox全选值,下面有个不错的示例,感兴趣的朋友可以参考下. 复制代码代码如下: <input type="checkbox" id=&q ...
- jQuery实现CheckBox全选、全不选
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
随机推荐
- Android IOS WebRTC 音视频开发总结(七八)-- 为什么WebRTC端到端监控很关键?
本文主要介绍WebRTC端到端监控(我们翻译和整理的,译者:weizhenwei,校验:blacker),最早发表在[编风网] 支持原创,转载必须注明出处,欢迎关注我的微信公众号blacker(微信I ...
- GitHub的.gitignore文件设置
用Eclipse连接GitHub 在本地仓库(最上层文件夹)建立.gitignore文件后,所有子文件夹下对应文件或者文件夹在submit的时候就会被忽略. 我将Eclipse的workspace当作 ...
- ue4框架C++语法汇总文章
1.Run external .exe file TCHAR* url = TEXT("C:\\windows\\system32\\calc.exe"); FPlatformPr ...
- 【转】Java关键字final、static使用总结
转自:http://lavasoft.blog.51cto.com/62575/18771/ Java关键字final.static使用总结 一.final 根据程序上下文环境, ...
- C# 时间函数相减
1:第一种方式: "; "; DateTime firstDateTemp = DateTime.ParseExact(firsttime, "yyyyMMddHHmms ...
- MySQL临时表创建
和SQL SERVER 创建临时表不同 不能直接写 Create table #Test_Table 而是需要在 Create 和 table 之间 加入 TEMPORARY(temporary< ...
- 代理模式(Proxy pattern)
代理模式(proxy pattern):作用:为其他对象提供一种代理,以控制对这个对象的访问.代理对象在客户端对象和目标对象之间起中介的作用. 代理模式涉及到的角色: 抽象角色:声明真实对象和代理对象 ...
- linux下dos环境和unix环境转换
DOS转UNIX::setfileformat=unix UNIX转DOS::setfileformat=dos and :set ff=unix
- nginx的优化
Nginx 优化 Nginx是俄罗斯人编写的十分轻量级的HTTP服务器,Nginx,它的发音为"engine X",是一个高性能的HTTP和反向代理服务器,同时也是一个IMAP/P ...
- ASP.NET Misconfiguration: Debug Information
Abstract: Debugging messages help attackers learn about the system and plan a form of attack. Explan ...