永久的CheckBox(单选,全选/反选)!
<html>
<head>
<title>选择</title>
<script type="text/javascript" src="jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$(function () {
//单选组事件
$("[name=chk]:checkbox").bind("click", function () {
if ($(this).attr("check")) {
$(this).removeAttr("check");
} else {
$(this).attr("check", true);
}
}) //全选或反选
$("[name=chkName]:checkbox").click(function () {
if ($(this).attr("check")) {
$(this).removeAttr("check");
$("[name=chk]:checkbox").each(function () {
if ($(this).attr("check")) {
$(this).click();
};
});
} else {
$(this).attr("check", true);
$("[name=chk]:checkbox").each(function () {
if (!$(this).attr("check")) {
$(this).click();
};
});
} }) $("#btnSub").click(function () {
var arr = [];
$("[name=chk]:checkbox").each(function () {
if ($(this).attr("check")) {
arr[arr.length] = $(this).attr("value");
}
})
alert(arr.join(","))
})
})
</script>
</head>
<body>
<div>
<div>
<span>
<input type="checkbox" id="chkAll" name="chkName" /></span>
</div>
<div>
<input type="checkbox" id="Checkbox1" name="chk" value="" />
<input type="checkbox" id="Checkbox2" name="chk" value="" />
<input type="checkbox" id="Checkbox3" name="chk" value="" />
<input type="checkbox" id="Checkbox4" name="chk" value="" />
</div>
<div>
<input type="button" id="btnSub" value="提交" />
</div>
</div>
</body>
</html>
永久的CheckBox(单选,全选/反选)!的更多相关文章
- checkbox、全选反选,获取值
<input id="Chk_All" onclick="CheckAll()" type="checkbox" /> < ...
- jquery控制动态生成的gridview中多列checkbox的全选反选及自动判断是否全选状态
动态生成的Gridview的前台html代码如下: <table class="usertableborder" cellspacing="0" ...
- jquery、js操作checkbox全选反选
全选反选checkbox在实际应用中比较常见,本文有个不错的示例,大家可以参考下 操作checkbox,全选反选//全选 function checkAll() { $('input[name=&qu ...
- jquery、js全选反选checkbox
操作checkbox,全选反选 //全选 function checkAll() { $('input[name="TheID"]').attr("checked&quo ...
- jQuery checkbox的全选与反选
1:checkbox的全选与反选 js 代码 $("#cbAll").click(function(){ if($("#cbAll").is(":ch ...
- jQuery全选/反选checkbox
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 通过VBA实现checkbox的全选和反选
checkbox的全选和反选可以通过VBA来控制,这种设计常见于一些交互式报表,代码如下: 1.分成两个IF判断 Private Sub CheckBox1_Click() ‘checkbox为总控 ...
- 表单javascript checkbox全选 反选 全不选
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http ...
- 关于Winform下DataGridView中实现checkbox全选反选、同步列表项的处理
近期接手一个winform 项目,虽然之前有.net 的经验,但是对一些控件的用法还不是很熟悉. 这段时间将会记录一些在工作中遇到的坎坷以及对应的解决办法,写出来与大家分享并希望大神提出更好解决方法来 ...
- 购物车功能:使用jQuery实现购物车全选反选,单选,商品增删,小计等功能
效果图: html: <!DOCTYPE html> <html lang="en"> <head> <meta charset=&quo ...
随机推荐
- mysql Host ‘XXXXXX’ is blocked because of many connection errors
mysql Host ‘XXXXXX’ is blocked because of many connection errors ERROR 1129 (00000): Host ‘XXXXXX’ i ...
- centos nginx,php添加到Service
SHELL脚本: nginx vim /etc/init.d/nginx #!/bin/sh # # nginx - this script starts and stops the nginx da ...
- C++排序函数sort/qsort使用
问题描述: C++排序函数sort/qsort的使用 问题解决: (1)sort函数使用 注: sort函数,参数1为数组首地址,参数2是数组 ...
- [C/CPP系列知识] C++中extern “C” name mangling -- Name Mangling and extern “C” in C++
http://www.geeksforgeeks.org/extern-c-in-c/ C++函数重载(function overloading),但是C++编译器是如何区分不同的函数的呢?----是 ...
- $POST数组论证($GET || $COOKIE || $REQUEST 同理)
我觉得还是有多个$_POST 如果只有一个$_POST,那么,多个人[同时]提交的话就不好处理 或者一个$_POST 时间限制(如同时钟周期)处理(不可能,不然响应没这么快) 或者 一个$_POS ...
- oracle 表空间 用户
Oracle创建表空间.创建用户以及授权.查看权限 创建临时表空间 CREATE TEMPORARY TABLESPACE test_temp TEMPFILE 'C:\oracle\product\ ...
- Installing Lua in Mac
Lua is distributed in source form. You need to build it before using it. Building Lua should be stra ...
- [转]ASP.NET Session 详解
来源:http://www.webshu.net/jiaocheng/programme/ASPNET/200606/1381.html 阅读本文章之前的准备 阅读本文章前,需要读者对以下知识有所了解 ...
- substr_replace()函数:将手机号中间4位隐藏为*号
<?php $mobile = "15810320826"; echo substr_replace($mobile,'****',3 , 4); ?> substr_ ...
- window.open(url, "_black" , spec)
var url = "${request.contextPath}/test/openWindow.action?number="+number; var spec = " ...