java script图片点击实现切换到下一张
点击图片切换下一张,循环切换,代码实现不了切换<script>vars=document.getElementById("s2");vara=newArray("imag...
点击图片切换下一张,循环切换,代码实现不了切换
<script>
var s=document.getElementById("s2");
var a=new Array("images/04.jpg","images/05.jpg","images/06.jpg");
var i=0;
function f()
{ i++;
if(i>2){
i=0;
}
s.src=a[i];
}
</script>
<style>
.s1{ font-size:60px;font-family:STCaiyun;background:linear-gradient(30deg,#ff00ff,#00ff00);width:100%;
height:14.5%;font-weight:bold;text-align:center; }
#s2{ margin-top:0.5%;opacty:0.2; }
</style>
<div class="s1">
<br>Music Wall
</div>
<div id="s2" >
<img src="images/04.jpg" width="1889" height="727" onclick="f()" >
</div>
求助 展开
<script>
var s=document.getElementById("s2");
var a=new Array("images/04.jpg","images/05.jpg","images/06.jpg");
var i=0;
function f()
{ i++;
if(i>2){
i=0;
}
s.src=a[i];
}
</script>
<style>
.s1{ font-size:60px;font-family:STCaiyun;background:linear-gradient(30deg,#ff00ff,#00ff00);width:100%;
height:14.5%;font-weight:bold;text-align:center; }
#s2{ margin-top:0.5%;opacty:0.2; }
</style>
<div class="s1">
<br>Music Wall
</div>
<div id="s2" >
<img src="images/04.jpg" width="1889" height="727" onclick="f()" >
</div>
求助 展开
3个回答
展开全部
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script>
var a=new Array("images/04.jpg","images/05.jpg","images/06.jpg");
var i=0;
function f()
{ i++;
if(i>2){
i=0;
}
document.getElementById("imageId").src = a[i];
}
</script>
<style>
.s1{ font-size:60px;font-family:STCaiyun;background:linear-gradient(30deg,#ff00ff,#00ff00);width:100%;
height:14.5%;font-weight:bold;text-align:center; }
#s2{ margin-top:0.5%;opacty:0.2; }
</style>
<div>
<br>Music Wall
</div>
<div id="s2" >
<img src="images/04.jpg" width="1889" height="727" onclick="f()" id="imageId">
</div>
</body>
</html>
追问
谢谢,你的我可以切换图片,但我的就是不行,几乎改得和你一样了,这里没空间发出,你看看私信
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询