老师为什么跟你写的代码一抹一样,可是单击按钮实现不了左右切换呀
<script>
window.onload = function () {
var container = document.getElementById('container');
var list = document.getElementById('list');
var buttons = document.getElementById('buttons').getElementsByTagName('span');
var prev = document.getElementById('prev');
var next = document.getElementById('next');
//封装
function animate(offset){
list.style.left = parseInt(list.style.left) - offset + 'px';
}
next.onclick = function(){
//list.style.left = parseInt(list.style.left) - 600 + 'px';
animate(-600);
}
prev.onclick = function(){
//list.style.left = parseInt(list.style.left) + 600 + 'px';
animate(600);
}
</script>