HTML页面

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<center>
<table>
<tr>
<th><input type="checkbox" class="che"></th>
<th>ID</th>
<th>用户名</th>
<th>分类</th>
<th>编辑</th>
</tr>
{volist name="data" id="v"}
<tr id="{$v.id}">
<td><input type="checkbox" class="check" value="{$v.id}" name=bb></td>
<td>{$v.id}</td>
<td>{$v.biao}</td>
<td>{$v.fen}</td>
<td><a href="javascript:void (0);" class="shan">删除</a></td>
</tr>
{/volist}
</table>
<button class="pi_shan">批量删除</button>
<button class="quan">全选</button>
<button class="quanbu">全不选</button>
</center>
<script src="__STATIC__/js/jquery.min.js"></script>
<script>
//批删
$(document).on("click",".pi_shan",function () {
bb=document.getElementsByName("bb");
str="";
for (var i=0;i<bb.length;i++)
{
if(bb[i].checked==true)
{
str+=","+bb[i].value
}
}
str=str.substr(1);
//请求
$.post(
"{:url('index/pi_del')}",
{
id:str
},
function (data) {
if(data==1)
{
alert("批删成功");
location.href="{:url('index/show')}"
}else if(data==2)
{
alert("批删失败");
}
}
)
})
//全选
$(document).on("click",".quan",function () {
$(".check").prop("checked",true);
})
//反选
$(document).on("click",".quanbu",function () {
$(".check").prop("checked",false);
})
//反选
$(document).on("click",".che",function () {
$(".check").each(function () {
this.checked=!this.checked;
})
})
//单删
$(document).on("click",".shan",function () {
var id=$(this).parents("tr").attr("id");
//请求
$.post(
"{:url('index/dan_shan')}",
{
id:id
},function (data) {
if(data==1)
{
document.getElementById(id).remove()
}
}
)
})
</script>
</body>
</html> PHP页面
<?php
namespace app\index\controller; use think\Controller;
use think\Db;
use think\Request; class Index extends Controller
{
public function index()
{
return '<style type="text/css">*{ padding: 0; margin: 0; } .think_default_text{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }</style><div style="padding: 24px 48px;"> <h1>:)</h1><p> ThinkPHP V5<br/><span style="font-size:30px">十年磨一剑 - 为API开发设计的高性能框架</span></p><span style="font-size:22px;">[ V5.0 版本由 <a href="http://www.qiniu.com" target="qiniu">七牛云</a> 独家赞助发布 ]</span></div><script type="text/javascript" src="https://tajs.qq.com/stats?sId=9347272" charset="UTF-8"></script><script type="text/javascript" src="https://e.topthink.com/Public/static/client.js"></script><think id="ad_bd568ce7058a1091"></think>';
}
//展示页面
public function show()
{
$data=Db::table("title")->select();
return view("show",['data'=>$data]);
}
//单删
public function dan_shan()
{
$id=Request::instance()->param("id");
$a=Db::table("title")->where("id=$id")->delete();
if($a)
{
return 1;
}else{
return 2;
}
}
//批删
public function pi_del()
{
$id=Request::instance()->param("id");
$aa=explode(",",$id);
$a=Db::table("title")->delete($aa);
if($a)
{
return 1;
}else{
return 2;
}
}
}
 

jquery中的全选、反选、全不选和单删、批删的更多相关文章

  1. 表单javascript checkbox全选 反选 全不选

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http ...

  2. ajax全选、全不选、反选、单删/批删

    <meta charset="utf-8"> <?php //链接数据库 $link = mysqli_connect('127.0.0.1','root','r ...

  3. 【HTML5】页面点击按钮添加一行 删除一行 全选 反选 全不选

    页面点击按钮添加一行    删除一行   全选   反选  全不选 页面效果图如下 html页面代码 <!DOCTYPE html> <html> <head> & ...

  4. 表单Checkbox全选反选全不选

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. vue实现单选多选反选全选全不选

    单选 当我们用v-for渲染一组数据的时候,我们可以带上index以便区分他们我们这里利用这个index来简单地实现单选 <li v-for="(item,index) in radi ...

  6. checkbook全选/反选/全不选

    <!doctype html><html lang="en"><head> <meta charset="UTF-8" ...

  7. Jquery中对checkbox的各种“全选”或者“取消”功能实现(特别注意1.6+的一定不能使用attr来取属性了!用prop!)

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  8. html js 全选 反选 全不选源代码

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...

  9. WPF DataGrid CheckBox 多选 反选 全选

    效果图 实现此效果的必要关键是 Style+DataTemplate 关键代码: <Window.Resources> <DataTemplate x:Key="Check ...

  10. js实现全选,反选,全不选

    思路:1.获取元素.2.用for循环历遍数组,把checkbox的checked设置为true即实现全选,把checkbox的checked设置为false即实现不选.3.通过if判断,如果check ...

随机推荐

  1. 彻底地/ 终于地, 解决 关于apache 权限的问题了:: 修改 DocumentRoot后的 403错误: have no permission to access / on this server

    目录的权限都 应该设置 为 drwxr_xr_x, 即755, 而html下的文件的权限设置为; 644 即可! -x 只有目标文件对某些用户是可执行的或该目标文件是目录时才追加x 属性. -w权限, ...

  2. 【Dalston】【第四章】容错保护(Hystrix)

    我们在实践微服务架构时,通常会将业务拆分成一个个微服务,微服务之间通过网络进行通信,进行互相调用,造成了微服务之间存在依赖关系.我们知道由于网络原因或者自身的原因,服务并不能保证服务的100%可用,如 ...

  3. 【第十七章】 springboot + devtools(热部署)

    技术介绍 devtools:是boot的一个热部署工具,当我们修改了classpath下的文件(包括类文件.属性文件.页面等)时,会重新启动应用(由于其采用的双类加载器机制,这个启动会非常快,如果发现 ...

  4. Python入门 值内存管理与所有的关键字

    值内存管理 Python采用的是基于值得内存管理方式,如果为不同变量赋值为相同值,这个值在内存中只有一份,多个变量指向同一块内存地址. id(x) : 用于返回变量所指值的内存地址 x = 3 pri ...

  5. MyEclipse代码编辑器中汉字太小的解决办法(中文看不清)

    问题描述:新安装的myeclipse 2014,代码编辑器中汉字很小看不清 解决办法:调整字体即可.通过菜单Windows——Preferences,输入font过滤选择Colors and Font ...

  6. oracle 之 统计函数、子查询、操作符

    统计函数 COUNT():查询表中的数据记录 AVG():求出平均值 SUM():求和 MAX():求出最大值 MIN():Q求出最小值 子查询   [单行多列] select * from a wh ...

  7. Ubuntu14.04下 升级 cmake

    参考: How to install cmake 3.2 on ubuntu 14.04? Ubuntu14.04下升级cmake 1.通过PPA安装: $ sudo apt-get install ...

  8. PHP中cookie思维导图

  9. Codeforces 769D k-Интересные пары чисел

    题目链接:http://codeforces.com/contest/769/problem/D 搜索题 考虑这些数的值域较小,直接${O(2^{k})}$次方枚举每个数字二进制位上是否改变,剪枝一下 ...

  10. 串口.Qt532测试(同步)

    环境:Win7x64.Qt5.3.2 MSVC OpenGL(x86).vs2010(x86) ZC:这里的例子是 同步的函数操作,貌似 如果子线程在等待 WaitCommEvent(...)或Rea ...