先看看弹窗效果,如下:
图片
$(page).on('click','.popupImage img',function () {
var that = $(this);
that.popupImage({
this:that,width:"200px"
})
});
shade = '<div class="shade" style="position:absolute; top:0; left:0; width: '+w+'px; height:'+h+'px;background: #000; z-index: 999990; opacity: .8;">
';
//相册弹窗
$.fn.popupImage = function (obj) {
var $this = obj.this;
var sj_w = $this[0].naturalHeight;
var src = $this.attr('src');
var h = $('body').height();
var w = $('body').width();
var padding = 10;
var shadeW = w - padding*2;
var img = '',shade = '';
img = '
' +
'<img src="'+src+'" style="max-width: '+shadeW+'px"/>
';'<img src="'+src+'" style="max-width: '+shadeW+'px"/>
shade = '<div class="shade" style="position:absolute; top:0; left:0; width: '+w+'px; height:'+h+'px;background: #000; z-index: 999990; opacity: .8;">
$('body').append(shade);
$('body').append(img);
$('.popup-image').on('click',function () {
$('.popup-image').remove();
$('.shade').remove();
})
};