<head>
<meta charset="UTF-8">
<title>2142013141</title>
<style>
#image {
display: block;
width: 500px;
height: 180px;
margin: 10px auto;
}
#next {
margin-left: 750px;
}
</style>
</head>
<body>
<img src="img/1.jpg" id="image"/>
<button id="next">next</button>
<button id="prev">prev</button>
<script>
Window.onload=function()
{
var image=document.getElementById("image");
var next=document.getElementById("next");
var prev=document.getElementById("prev");
var nowIndex=1;
var count=6;
next.onclick = function(){
nowIndex=nowIndex+1>count?1:nowIndex+1;
image.src="img/"+nowIndex+".jpg";}
prev.onclick = function(){
nowIndex = nowIndex<=1?count:nowIndex-1;
image.src="img/"+nowIndex+".jpg";}
}
</script>
</body>
第22行的window的w要小写
Window.onload=function() => window.onload=function()
而且你script标签是在按钮和图片创建后执行的,window.onload事件完全可以删除
采纳一下哈