---
title: "作品-：jquery的图片动态弹出特效"
author: "piperzero"
date: "2013-06-15T23:52:00Z"
tags: []
slug: "jquery"
draft: false
lastmod: "2013-07-16T08:31:48Z"
id: 1906878
url: "https://piperzero.iteye.com/blog/1906878"
---

&lt;html&gt;  
&lt;head&gt;  
&lt;style type='text/css'&gt;  
#theImage{  
float:left;  
padding:5px 5px 5px 0;  
}  
&lt;/style&gt;  
&lt;script src="js/jquery-1.5.1.js" type="text/javascript"&gt;&lt;/script&gt;  
&lt;script type='text/javascript'&gt;  
$(document).ready(function(){  
$('#theImage').click(function(){  
var background=$('&lt;div/&gt;');  
$(background).attr('id','overlayBackground')  
.animate({  
'opacity':'0.8'},  
1000\)  
.css(  
{  
"display": "block",  
"position": "absolute",  
"left": 0,  
"top": 0,  
"backgroundColor": "#ccc",  
"opacity": "0.8",  
"width": $(document).width(),  
"height": $(document).height(),  
"zIndex": 100  
}  
);  
$('body').append(background);  
//  
var newImage=$('&lt;img/&gt;');  
var width=$('body').width();  
var height=$('body').height();  
$(newImage).attr('src',$(this).attr('src'))  
.attr('id','largeImage')  
.css({  
'display':'none',  
'position':'absolute',  
'top':height/2-400/2,  
'left':width/2-600/2,  
'width':600,  
'height':400,  
'zIndex':101  
});  
$('body').append(newImage)  
$(newImage).fadeIn(2000,function(){  
$(this).bind('click',function(){  
$(this).fadeOut(1000);  
$('div#overlayBackground').fadeOut(1000,function(){  
$(this).remove();  
});  
});  
});  
});  
});  
$('body').append('background');  
&lt;/script&gt;  
&lt;/head&gt;  
&lt;body&gt;  
&lt;p&gt;  
&lt;img src='images/londoneye.jpg' style="width:150px;height:150px" id='theImage'&gt;  
点击小图，会自动弹出大图  
&lt;/p&gt;  
&lt;/body&gt;

&lt;/html&gt;

![](http://img.blog.csdn.net/20130615235149250)