jquery+tp3實現賬號是否被禁用的即點即改
阿新 • • 發佈:2018-07-13
url init radi col 是否 ext 角色 back ==
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實現賬號是否被禁用的即點即改