.className问题 ,加粗部分
</style>
<script>
window.onload = function(){
var container = document.getElementById('container');
var listImg = document.getElementById('listImg');
var buttons = document.getElementById('buttons');
var next = document.getElementById('next');
var prev = document.getElementById('prev');
var index = 1;
function animate(offset){
var newlist = parseInt(listImg.style.left)+offset;
listImg.style.left = newlist + 'px';
if(newlist > -700){
listImg.style.left = -3500 + 'px';
}
if(newlist < -3500){
listImg.style.left = -700 + 'px';
}
}
function showButtons(){
buttons[index-1].className = 'on'; 在这用className浏览器报 ‘Uncaught TypeError: Cannot set property 'className' of undefined ’ 这个错呢
}
next.onclick = function(){
showButtons();
animate(-700);
}
prev.onclick = function(){
animate(700);
}
}
</script>