解析 'left' 的值时出错。 声明被丢弃。
在javascript 也加了+"px" 就是找不到出了什么问题
html部分:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>焦点轮播图</title>
<link rel="stylesheet" type="text/css" href="css/style2.css" type="text/css">
<script type="text/javascript" src="js/jq3.js"></script>
</style>
<script type="text/javascript" src="js/01.js">
</script>
</head>
<body>
<div id="container">
<div id="list" >
<img src="img/5副本.jpg" alt="1" style='left:-600px;'/>
<img src="img/1副本.jpg" alt="1"/>
<img src="img/2副本.jpg" alt="2"/>
<img src="img/3副本.jpg" alt="3"/>
<img src="img/4副本.jpg" alt="4"/>
<img src="img/5副本.jpg" alt="5"/>
<img src="img/1副本.jpg" alt="5"/>
</div>
<div id="buttons">
<span index="1" class="on"></span>
<span index="2"></span>
<span index="3"></span>
<span index="4"></span>
<span index="5"></span>
</div>
<a href="javascript:;" id="prev" class="arrow"><</a>
<a href="javascript:;" id="next" class="arrow">></a>
</div>
</body>
</html>
javascript部分
window.onload=function(){
var containers=document.getElementById("container");
var buttons=document.getElementById("buttons").getElementsByTagName("span");
var list=document.getElementById("list");
var prev=document.getElementById("prev");
var next=document.getElementById("next");
var indent=1;
function go(offset){
list.style.left=parseInt(list.style.left)+offset+"px";
//console.log(list.style.left);
}
next.onclick=function(){
go(-600);
}
prev.onclick=function(){
go(600);
}
}