这个JS在IE6不好使啊
(function () {
var imgbox = document.getElementById("imgbox");
var pic_list = document.getElementById("pic_list");
var pics = pic_list.getElementsByTagName("li");
var button = document.getElementById("button").getElementsByTagName("li");
var p;
var start;
function autoplay(start) {
for (i = start; i < button.length; i++) { //设置起始值为start参数.
(function () {
var p = i; // 为p赋值i. i等于0,1,2,3,4;
button[i].onmouseover = function change() {
for (j = 0; j < this.parentNode.childNodes.length; j++) {
this.parentNode.childNodes[j].className = "";
}
this.className = "current";
for (m = 0; m < pics.length; m++) {
pics[m].className = "";
if (m == p) {
pics[m].className = "show";
}
}
}
})();
}
}
autoplay(0);
})();
这个JS在ie6中不能用啊,请各位大大帮忙改下,既能在ie7、8中用,也能在ie6中用。谢谢!
------解决方案--------------------
把所有形如
this.parentNode.childNodes[j].className = "";
的,都改为形如
this.parentNode.childNodes[j].setAttribute("class", "");
this.parentNode.childNodes[j].setAttribute("className", "");
这样