我想用javascript做一个图片自动切换的效果,大神帮我看看这段代码哪儿出了问题,为什么没效果?
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript" src="scripts/jquery-1.11.1.min.js" ></script>
<style type="text/css">
#cImageroll{
height:320px;
overflow:hidden;
width:560px;
position:relative;
}
#cImageroll img{
position:absolute;
left:0;
top:0;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
var index=0;
var adTimer=setInterval(function(){
showImg(index);
index++;
if(index==5){index=0;}
},5000);
function showImg(index){
$("JS_imgWrap").find("img").eq(index).fadeIn()
.siblings().fadeOut();
}
})
</script>
</head>
<body>
<div id="cImageroll">
<a href="#" id="JS_imgWrap">
<img src="images/男装.jpg" alt="男装"/>
<img src="images/女装.jpg" alt="女装"/>
<img src="images/箱包.jpg" alt="箱包"/>
<img src="images/鞋子.jpg" alt="鞋子"/>
<img src="images/眼镜.jpg" alt="眼镜"/>
</a>
</div>
</body>
</html> 展开
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript" src="scripts/jquery-1.11.1.min.js" ></script>
<style type="text/css">
#cImageroll{
height:320px;
overflow:hidden;
width:560px;
position:relative;
}
#cImageroll img{
position:absolute;
left:0;
top:0;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
var index=0;
var adTimer=setInterval(function(){
showImg(index);
index++;
if(index==5){index=0;}
},5000);
function showImg(index){
$("JS_imgWrap").find("img").eq(index).fadeIn()
.siblings().fadeOut();
}
})
</script>
</head>
<body>
<div id="cImageroll">
<a href="#" id="JS_imgWrap">
<img src="images/男装.jpg" alt="男装"/>
<img src="images/女装.jpg" alt="女装"/>
<img src="images/箱包.jpg" alt="箱包"/>
<img src="images/鞋子.jpg" alt="鞋子"/>
<img src="images/眼镜.jpg" alt="眼镜"/>
</a>
</div>
</body>
</html> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询