分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 运营维护

jquery+tp3实现账号是否被禁用的即点即改

发布时间:2023-09-06 02:04责任编辑:蔡小小关键词:暂无标签

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>管理员列表</title> ???<style> ???????.gre{ ???????????margin-left: 10px; ???????????background: lightgreen; ???????????border-radius: 5px; ???????????color: white; ???????????text-decoration: none; ???????} ???????.danger{ ???????????margin-left: 10px; ???????????background: red; ???????????border-radius: 5px; ???????????color: white; ???????????text-decoration: none; ???????} ???</style></head><body><table> ???<tr> ???????<th>ID</th> ???????<th>账号</th> ???????<th>班级</th> ???????<th>角色</th> ???????<th>权限</th> ???????<th>状态</th> ???????<th>操作</th> ???</tr><foreach name="list" item="v"> ???<tr id="{$v.id}"> ???????<td>{$v.id}</td> ???????<td>{$v.uname}</td> ???????<td>{$v.class_name}</td> ???????<td>{$v.rname}</td> ???????<td> ???????????<foreach name="v.nname" item="vo"> ???????????????<a href="#" style="margin-left: 10px; background: #66c9f3; border-radius: 5px;color: white;text-decoration: none;">{$vo}</a> ???????????</foreach> ???????</td> ???????<td> ???????????<if condition="$v.is_clock eq 1"><a href="javascript:void(0);" class="gre clock">正常</a> ???????????????<else /> <a href="javascript:void(0);" class="danger clock">被禁</a> ???????????</if> ???????</td> ???????<td> ???????????<a>删除</a> ???????</td> ???</tr></foreach> ???<script src="__PUBLIC__/js/jquery.js"></script> ???<script> ???????????$(‘.clock‘).on(‘click‘,function () { ???????????????var is_clock = $(this).text(); ???????????????var id = $(this).parents("td").parents().attr(‘id‘); ???????????????if(is_clock==‘正常‘){ ???????????????????var is_c = 2; ???????????????????$(this).html("被禁"); ???????????????????$(this).removeClass(‘gre‘); ???????????????????$(this).addClass(‘danger‘); ???????????????}else{ ???????????????????var is_c = 1; ???????????????????$(this).html("正常"); ???????????????????$(this).removeClass(‘danger‘); ???????????????????$(this).addClass(‘gre‘); ???????????????} ???????????????//请求 ???????????????$.get("__URL__/update_clock?is_c="+is_c+"&id="+id,function (data) { ???????????????????// alert(data); ???????????????}); ???????????}); ???</script></table></body></html>

php页面

//修改状态 ???public function update_clock(){ ???????$id = I(‘get.id‘); ???????$data[‘is_clock‘] = I(‘get.is_c‘); ???????M("user")->where("uid=".$id)->save($data); ???}

效果:

jquery+tp3实现账号是否被禁用的即点即改

原文地址:https://www.cnblogs.com/hopelooking/p/9307400.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved