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. bzoj1741 [Usaco2005 nov]Asteroids 穿越小行星群 最小点覆盖

    链接 https://www.lydsy.com/JudgeOnline/problem.php?id=1741 思路 消除所有的小行星 每个点(x,y)只有选择x或者y才能被覆盖 二分图最小点覆盖= ...

  2. P2761 软件补丁问题

    P2761 软件补丁问题 思路 貌似不用网络流,直接状态压缩 用spfa跑最短路,直接判断是否能过 位运算太渣了,WA了好几发 代码 #include <bits/stdc++.h> us ...

  3. MySQL 命令操作数据表

    MySQL 命令操作数据表 1.查看表信息 desc hs_user_credit_info; 2.新增表字段 alter table hs_credit_order add search_relat ...

  4. SP3946 MKTHNUM - K-th Number(整体二分)

    思路 整体二分的板子题,没什么思路好说 代码 #include <cstdio> #include <algorithm> #include <cstring> u ...

  5. go 依赖工具glide

    添加gopath/bin目录到环境变量下 安装glide $ go get github.com/Masterminds/glide $ go install github.com/Mastermin ...

  6. Druid介绍2

    Druid的发送数据和查询数据 Druid 开篇 - 大数据实时探索性分析平台 官网 Druid 一次海量数据实时处理的实践 使用HDFS作为Druid的deepStorage 在哪里下载druid ...

  7. gawk命令详解

    GNU awk: sort.cut.uniq.wc等参考: https://blog.csdn.net/lk07828/article/details/46324807 https://blog.cs ...

  8. BZOJ 1061: [Noi2008]志愿者招募(线性规划与网络流)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1061 题意: 思路: 直接放上大神的建模过程!!!(https://www.byvoid.com/z ...

  9. python 安装插件 requests、BeautifulSoup

    安装第三方插件库 1. requests  , 下载地址 https://github.com/requests/requests 安装: 利用 pip 安装 pip3 install request ...

  10. Mysql 强行Kill 连接

    BEGIN ; ; ; DO KILL @Temp; ; END WHILE ; END