当鼠标悬在layui表格里的图片上,图片显示大图

实现下面这种效果

<table class="layui-hide" id="userinfo" lay-filter="userinfo"></table>
layui.use('table', function () {
            var table = layui.table;
            table.render({
                elem: '#userinfo'
                , url: '__URL__/guide_info'
                , method: 'post'
                , page: true
                , limit: 10
                , width: 1540
                , cols: [[
                    { field: 'imageurl', title: '引导图', width: 200,  align: 'center', event: 'showImage' }
                    , { field: 'description', title: '图片描述', width: 400, align: 'center', }
                    , { field: 'sequence', title: '图片次序', width: 120, sort: true, align: 'center' }
                    , { field: 'categoryname', title: '行业', width: 100, align: 'center' }
                    , { field: 'organizename', title: '组织', width: 280, sort: true, align: 'center' }
                    , { field: 'enable', title: '是否可用', width: 100, align: 'center' }
                    , { field: 'createtime', title: '创建时间', width: 180, align: 'center' }
                    , { fixed: 'right', title: '操作', toolbar: '#barDemo', width: 150 }
                ]]
                , id: 'testReload'
                , done: function (res, curr, count) {
                    hoverOpenImg();//显示大图
                    res.data.forEach(function (data) {
                        var id = data.id;
                        var enable = data.enable;
                        // 显示启用或禁用按钮
                        if (enable == "不可用") {
                            $('#start_using_' + id).show();
                        } else {
                            $('#stop_using_' + id).show();
                        }
                    })
                }
            });
           
            function hoverOpenImg() {
                var img_show = null;
                $('td img').hover(function () {
                    var img = "<img class='img_msg' src='" + $(this).attr('src') + "' style='width:300px;' />";
                    img_show = layer.tips(img, this, {
                        tips: [2, 'rgba(41,41,41,.5)']
                        , area: ['330px']
                    });
                }, function () {
                    layer.close(img_show);
                });
                $('td img').attr('style', 'max-width:70px');
            }
}

生成表格后在done方法里渲染就可以了。

完结撒花。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夏木子杉

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值