好友
阅读权限30
听众
最后登录1970-1-1
|
甜萝
发表于 2021-11-27 13:42
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
*{
margin: 0;
padding: 0;
}
#bj{
width: 800px;
margin: 0 auto;
padding: 30px;
background-color: #84fab0;
text-align: center;
}
</style>
<script>
window.onload = function(){
var prev = document.getElementById("prev");
var next = document.getElementById("next");
var img = document.getElementsByTagName("img")[0];
var imgArr = ["C:\Users\33943\.cache\前端\img\357dd0f1fd052ffe3dce1f9eb5e7cff6.jpeg","C:\Users\33943\.cache\前端\img\27393a4ed82bae144b515038a5afde5d.jpeg"];
var index = 0;
prev.onclick = function(){
index--;
img.src = imgArr[index];
}
next.onclick = function(){
index++;
img.src = imgArr[index];
}
}
</script>
</head>
<body>
<div id="bj">
<img src="C:\Users\33943\Downloads\d629294b00dd442bd9a3c8ef54c33be7.jpeg" alt="图片"><br>
<button id="prev">上一张</button>
<button id="next">下一张</button>
</div>
</body>
</html>
如题 图片一直无法切换 也不知道是是啥原因导致的 有大神知道吗? |
|
发帖前要善用【论坛搜索】功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。 |
|
|
|
|