我想了一个更好地showbtn
var showBtn = function(){
for(var i = 0,len = btn.length; i < len ; i ++){
btn[i].className = '';
}
var picLeft = parseInt(pic.style.left);
var whichBtn = Math.round(Math.abs(picLeft)/600);
index = whichBtn;
btn[index - 1].className = 'onpic';
}
var showBtn = function(){
for(var i = 0,len = btn.length; i < len ; i ++){
btn[i].className = '';
}
var picLeft = parseInt(pic.style.left);
var whichBtn = Math.round(Math.abs(picLeft)/600);
index = whichBtn;
btn[index - 1].className = 'onpic';
}
最新回答 / 胖脸猫
var buttons=document.getElementById("buttons").document.getElementsByTagName("span");var buttons = document.getElementById('buttons').getElementsByTagName('span'); 这个是常见写法 你好像多了个document
2015-10-18