这才是真正的正确代码!!!
老师的代码有误
都不知到老师那个怎么运行的,我照他写的就是动不了,直到看到你这个:
function bind(eventType,callback,false){
if(typeof el.addEventListener === "function"){
el.addEventListener(eventType, callback,false);
}else if(typeof el.attachEvent === "function"){
el.attachEvent("on" + eventType,callback);
}
}
呵呵,bind里边我传了eventType,callback,false后来可以了
window.onload=function(){
function bind(el,eventType, callback){
if(typeof el.addEventListener === "function"){
el.addEventListener(eventType, callback,false);
}else if(typeof el.attachEvent === "function"){
el.attachEvent("on" + eventType,callback);
}
}
function mouseoverHandler(e){
var target = e.target || e.srcElement;
var list = document.getElementsByTagName("li");
for(var i = 0; i < list.length; i++){
list[i].className = "";
}
while(target.tagName != "LI" && target.tagName != "BODY"){
target = target.parentNode;
}
target.className = "big";
}
function initList(){
var list = document.getElementsByTagName("li");
for(var i=0; i < list.length; i++){
bind(list[i],"mouseover", mouseoverHandler);
}
}
initList();
}
举报