JQ checkbox 全选 反选获取值
来源:互联网 发布:高仿球鞋的淘宝店 编辑:程序博客网 时间:2024/05/17 22:35
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script type="text/javascript" src="js/jquery-2.1.4.min.js"></script>
</head>
<body>
<form name="myform" action="#" method="post">
<input class="select" type="checkbox" name="check[]" value="1" "/>1<p/>
<input class="select" type="checkbox" name="check[]" value="2" "/>2<p/>
<input class="select" type="checkbox" name="check[]" value="3" "/>3<p/>
<input class="select" type="checkbox" name="check[]" value="4" "/>4<p/>
<input class="select" type="checkbox" name="check[]" value="5" "/>5<p/>
<input type="checkbox" id="selectall"/>全选
<input type="checkbox" id="selectanone"/>全不选
<input type="checkbox" id="selectfan"/>反选<p/>
<input type="submit" name="submit"></button>
</form>
<div></div>
<script type="text/javascript">
$(document).ready(function(){
//全选
$("#selectall").click(function () {
if(this.checked==true){
$(".select").attr("checked", true);
}else{
$(".select").attr("checked", false);
};
});
//全不选
$("#selectanone").click(function () {
$(".select").attr("checked", false);
});
//反选
$("#selectfan").click(function () {
$(".select").each(function () {
this.checked=!this.checked;
});
});
//获取值
$("input[type='submit']").click(function(){
var checkvalue=[];
$(".select:checked").each(function(){
checkvalue.push($(this).val());
});
alert(checkvalue);
// $("div").html(checkvalue);
});
});
</script>
</body>
</html>;
<html>
<head>
<meta charset="utf-8">
<title></title>
<script type="text/javascript" src="js/jquery-2.1.4.min.js"></script>
</head>
<body>
<form name="myform" action="#" method="post">
<input class="select" type="checkbox" name="check[]" value="1" "/>1<p/>
<input class="select" type="checkbox" name="check[]" value="2" "/>2<p/>
<input class="select" type="checkbox" name="check[]" value="3" "/>3<p/>
<input class="select" type="checkbox" name="check[]" value="4" "/>4<p/>
<input class="select" type="checkbox" name="check[]" value="5" "/>5<p/>
<input type="checkbox" id="selectall"/>全选
<input type="checkbox" id="selectanone"/>全不选
<input type="checkbox" id="selectfan"/>反选<p/>
<input type="submit" name="submit"></button>
</form>
<div></div>
<script type="text/javascript">
$(document).ready(function(){
//全选
$("#selectall").click(function () {
if(this.checked==true){
$(".select").attr("checked", true);
}else{
$(".select").attr("checked", false);
};
});
//全不选
$("#selectanone").click(function () {
$(".select").attr("checked", false);
});
//反选
$("#selectfan").click(function () {
$(".select").each(function () {
this.checked=!this.checked;
});
});
//获取值
$("input[type='submit']").click(function(){
var checkvalue=[];
$(".select:checked").each(function(){
checkvalue.push($(this).val());
});
alert(checkvalue);
// $("div").html(checkvalue);
});
});
</script>
</body>
</html>;
0 0
- JQ checkbox 全选 反选获取值
- checkbox 全选、全不选、反选、提交获取选中值
- checkbox全选反选
- checkbox 全选 反选
- checkbox全选反选
- checkbox,全选,反选
- checkbox全选反选
- jq获取复选框的值(全选,反选等)
- checkbox全选和反选
- jquery checkbox 全选 反选
- checkbox全选/反选 动画版
- checkbox 全选 与 反选
- checkbox全选与反选
- checkbox全选与反选
- checkbox全选和反选
- checkbox全选和反选
- checkbox全选和反选
- jQuery CheckBox全选、反选
- android---线性布局
- 模式识别:k-均值聚类算法的研究与实现
- ios UITableView separatorColor 默认颜色
- java处理图片--图片的缩放,旋转和马赛克化
- Android FragmentStatePagerAdapter.notifyDataSetChanged()刷新数据的问题
- JQ checkbox 全选 反选获取值
- Can you find it?
- 可变参数列表及printf函数的实现
- 有一个一维数组,里面放入十个学生的成绩,写一个函数,求出平均分,最高分和最低分(用全局变量的方法)
- 渣渣ACM日记——1009-FatMouse' Trade (HDOJ)
- file.toURI().toURL()
- Shell
- 获取某个网页的源代码显示在手机界面上
- 认识自己——人的野心和目标