Layui简单图片放大

html部分

<img src="图片地址" onclick="showImg('名称','图片地址')" style="height: 30px;cursor: pointer;">

js部分

<script>
function showImg(name, url) {
    layer.open({
        type: 1,
        title: false,
        closeBtn: 0,
        shadeClose: true,
        area: ['300px'],
        content: "<img alt=" + name + " title=" + name + " src=" + url + " style='width:300px;' />"
    });
}
</script>
记得引入layer https://www.layuicdn.com/layui-v2.5.5/layui.js

猜你喜欢

转载自blog.csdn.net/qq_15957557/article/details/103783761