码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2018-07-13 21:28:35      阅读:285      评论:0      收藏:0      [点我收藏+]

标签:.text   doc   pre   utf-8   span   script   round   lock   name   

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实现账号是否被禁用的即点即改

标签:.text   doc   pre   utf-8   span   script   round   lock   name   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!