jQuery 淡出一張圖片到另一張圖片,例如有下邊的 html:
復制代碼 代碼如下:
<div>
<img src="1.jpg" />
</div>
復制代碼 代碼如下:
.fade
{
background-image:url('images/2.jpg');
width:300px;
height:225px;
}
復制代碼 代碼如下:
$(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);
});
});
復制代碼 代碼如下:
<div><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>
新聞熱點
疑難解答
圖片精選