yii中jquery全选 全不选 全选全部选 反选
来源:互联网 发布:mac可以下载爱思助手 编辑:程序博客网 时间:2024/05/16 06:06
<!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" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Document</title>
</head>
<body>
<center>
<form action="">
<table border='1'>
<tr>
<td>id</td>
<td>用户名</td>
<td>密码</td>
<td>操作</td>
<td>图片</td>
</tr>
<?php foreach ($data as $v) {?>
<tr>
<td><input type="checkbox" name='box' value="<?php echo $v['id'];?>"/><?php echo $v['id'];?></td>
<td><?php echo $v['u_name'];?></td>
<td><?php echo $v['u_pwd'];?></td>
<td><img src="<?php echo $v['u_file']?>" width="50" /></td>
<td>
<a href="index.php?r=index/delete&id=<?=$v['id']?>">删除</a>
<a href="index.php?r=index/update&id=<?=$v['id']?>">修改</a>
</td>
</tr>
<?php } ?>
</table>
<input type="checkbox" id="post" /> 全选
<input type="button" value="全选" id="posts" />
<input type="button" value="全不选" id="pos" />
<input type="button" value="全选全不选" id="qf" />
<input type="button" value="反选" id="fx" />
<input type="button" value="确定" id="getadd" />
<div id="arr"></div>
<?php
use yii\widgets\LinkPager;
echo LinkPager::widget(['pagination' => $pages]);
?>
</form>
</center>
<script type="text/javascript" src="jquery.1.12.js"></script>
<script>
$(function(){
//获取id
$("#getadd").click(function() {
text = $("input:checkbox[name='box']:checked").map(function(index,elem) {
return $(elem).val();
}).get().join(',');
//$('#arr').val(text);
alert("选中的checkbox的值为:"+text);
});
});
//全选
$("#posts").click(function(){
$(":input[name='box']").prop("checked",true);
})
//全不选
$("#pos").click(function(){
$(":input[name='box']").prop("checked",false);
})
//全选全不选
$("#qf").click(function(){
var box = $(":input[name='box']");
if(box.prop("checked") == false)
{
box.prop("checked",true);
}
else
{
box.prop("checked",false);
}
})
//反选
$("#fx").click(function(){
var box = $(":input[name='box']");
box.each(function(){
this.checked=!this.checked;
})
})
</script>
</body>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Document</title>
</head>
<body>
<center>
<form action="">
<table border='1'>
<tr>
<td>id</td>
<td>用户名</td>
<td>密码</td>
<td>操作</td>
<td>图片</td>
</tr>
<?php foreach ($data as $v) {?>
<tr>
<td><input type="checkbox" name='box' value="<?php echo $v['id'];?>"/><?php echo $v['id'];?></td>
<td><?php echo $v['u_name'];?></td>
<td><?php echo $v['u_pwd'];?></td>
<td><img src="<?php echo $v['u_file']?>" width="50" /></td>
<td>
<a href="index.php?r=index/delete&id=<?=$v['id']?>">删除</a>
<a href="index.php?r=index/update&id=<?=$v['id']?>">修改</a>
</td>
</tr>
<?php } ?>
</table>
<input type="checkbox" id="post" /> 全选
<input type="button" value="全选" id="posts" />
<input type="button" value="全不选" id="pos" />
<input type="button" value="全选全不选" id="qf" />
<input type="button" value="反选" id="fx" />
<input type="button" value="确定" id="getadd" />
<div id="arr"></div>
<?php
use yii\widgets\LinkPager;
echo LinkPager::widget(['pagination' => $pages]);
?>
</form>
</center>
<script type="text/javascript" src="jquery.1.12.js"></script>
<script>
$(function(){
//获取id
$("#getadd").click(function() {
text = $("input:checkbox[name='box']:checked").map(function(index,elem) {
return $(elem).val();
}).get().join(',');
//$('#arr').val(text);
alert("选中的checkbox的值为:"+text);
});
});
//全选
$("#posts").click(function(){
$(":input[name='box']").prop("checked",true);
})
//全不选
$("#pos").click(function(){
$(":input[name='box']").prop("checked",false);
})
//全选全不选
$("#qf").click(function(){
var box = $(":input[name='box']");
if(box.prop("checked") == false)
{
box.prop("checked",true);
}
else
{
box.prop("checked",false);
}
})
//反选
$("#fx").click(function(){
var box = $(":input[name='box']");
box.each(function(){
this.checked=!this.checked;
})
})
</script>
</body>
</html>
0 0
- yii中jquery全选 全不选 全选全部选 反选
- jQuery实现全选,全部选,反选
- jquery实现全选,全部取消,反选
- JQuery 全选 全不选 反选
- jQuery全选、反选、全不选
- jquery-全选-反选-全不选
- jQuery全选,全不选,反选
- 全选、全部选、反选
- jquery全选反选
- jquery 全选反选
- Jquery 全选、反选
- jquery -全选/反选
- Jquery 全选,反选
- Jquery 全选 反选
- jquery全选反选
- jquery--全选反选
- jQuery全选反选
- Jquery 全选/反选
- 肯尼亚央行:利率上限可能打击商业银行贷款
- MyBatis中#{}和${}的区别详解
- 学习Android CoordinatorLayout(一)
- android Sqlite数据库使用方法小例
- laravel - 中间件使用
- yii中jquery全选 全不选 全选全部选 反选
- Zookeeper的几个应用场景
- 多ajax请求的各类解决方案(同步, 队列, cancel请求)
- 21. Upgrade-Insecure-Requests: 1
- 购物车伸缩功能,像美团外卖购物车。
- delphi hook alt+F4 ctrl+delete+alt win键等
- printf 字符串格式化 %6.9s %*.s
- PYQT笔记——QFileDialog
- 冒泡排序