为什么下面的原点没反应
var img = document.getElementById("img"); var btn = document.getElementById("btn").getElementsByTagName("span"); var a1 = document.getElementById('a1'); var a2 = document.getElementById('a2'); var add = 1; function show(){ for (var i = 0; i < btn.length ; i++) { if( btn[i].className == 'on'){ btn[i].className = ''; break; } } btn[add - 1].className = 'on';这里报错Uncaught TypeError: Cannot set property 'className' of undefined }