- En primer lugar, escribir sobre el método de vista previa
function previewImg(obj) {
var img = new Image();
img.src = obj.src;
var imgHtml = "<img src='" + obj.src + "' />";
//弹出层
layer.open({
type: 1,
shade: true,
title: false, //不显示标题
area:['auto','auto'],
content: imgHtml, //捕获的元素,注意:最好该指定的元素要存放在body最外层,否则可能被其它的相对元素所影响
cancel: function () {
}
});
}
- A continuación, obtener el objeto de página img y añadir un evento de clic
//图片预览事件
$("#post-content figure img").each(function() {
$(this).click(function() {
previewImg(this);
})
});