加载图片后如何淡入效果?
加载图片后
怎么加淡入效果?
代码如下:
onload = function() {
$('#bg').attr('src','1.jpg');
}
------解决方案--------------------<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<!-- 引入jQuery -->
<script src="../scripts/jquery-1.3.1.js" type="text/javascript"></script>
<style>
.header{
background:#fff url(images/banner_05a.jpg) no-repeat;
height:133px;
width:963px;
float:left;
position:relative;
}
.header img {
vertical-align:top;
position:absolute;
right:0;
}
</style>
<script language="javascript" type="text/javascript">
$(function(){
$(".header img").fadeOut(0).eq(0).fadeIn(0);
var i = 0;
setInterval(function(){
if($(".header img").length > (i+1)){
$(".header img").eq(i).fadeOut(2000).next("img").fadeIn(2000);
i++;
}
else{
$(".header img").eq(i).fadeOut(2000).siblings("img").eq(0).fadeIn(2000);
i = 0;
}
},3000);
})
</script>
</head>
<body>
<div class="header">
<img alt="JQuery实现淡入淡出效果" src="templatemo_image_01.jpg">
<img alt="JQuery实现淡入淡出效果" src="templatemo_image_02.jpg">
<img alt="JQuery实现淡入淡出效果" src="templatemo_image_03.jpg">
</div>
</body>
</html>
试一下!