欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jQuery 淡出一個圖像到另一個圖像的實現(xiàn)代碼

 更新時間:2013年06月12日 12:34:14   作者:  
這篇文章主要介紹了jquery的hover事件實現(xiàn)兩個圖片的淡出切換效果,需要的朋友可以參考下
jQuery 淡出一張圖片到另一張圖片,例如有下邊的 html:

復制代碼 代碼如下:

<div class="fade">
<img src="1.jpg" />
</div>


首先,確保 div 的大小和圖片大小一樣,這個 div 有另一個背景圖,如下:

css代碼:

復制代碼 代碼如下:

.fade
{
background-image:url('images/2.jpg');
width:300px;
height:225px;
}


jQuery 代碼如下:

復制代碼 代碼如下:

$(document).ready(function () {
$(".fade").hover(function () {
$(this).find("img").stop(true, true).animate({ opacity: 0 }, 500);
}, function () {
$(this).find("img").stop(true, true).animate({ opacity: 1 }, 500);
});
});


完整實現(xiàn)代碼:

復制代碼 代碼如下:

<div class="fade"><img src="1.jpg" /></div>
<style type="text/css">
.fade
{
background-image:url('2.jpg');
width:300px;
height:225px;
margin:0 auto 15px;
}</style>
<script type="text/javascript">
$(document).ready(function () {
$(".fade").hover(function () {
$(this).find("img").stop(true, true).animate({ opacity: 0 }, 500);
}, function () {
$(this).find("img").stop(true, true).animate({ opacity: 1 }, 500);
});
});
</script>


作者:jQuery學習

相關文章

最新評論