1.創建viewer視圖
$(document).on('mousedown','.credentialsImg',function () { if($(this).attr('src')){ $(this).viewer( { 'hidden': function (e) { console.log(e.type); }, } ); } else{ return false; } });
2.銷燬視圖
delImg: function (self) { $(self).parent().find('img').attr('src',''); $(self).parent().find('img').removeClass('credentialsImg'); $(self).parent().find('img').viewer('destroy'); $(self).parent().find('img').data('src',''); $(self).css('z-index','-2'); $('#'+$(self).parent().find('img').attr('id')).off('click'); $('#'+$(self).parent().find('img').attr('id')).on('click',function(){ tool.upLoad($(self).parent().attr('id'),$(self).parent().attr('id').replace(/upload/,''),$(self).parent().find('img').attr('id')); }) },