function bind(el,eventType, callback){
if(typeof el.addEventListener === "function"){
el.addEventListener(el,eventType, callback,false);
}else if(typeof el.attechEvent === "function"){
el.attechEvent("on" + eventType,callback);
}
}
function mouseoverHandler(e){
var target = e.target || e.srcElement;
var outer = document.getElementById("subject");
var list = outer.getElementsByTagName("li");
for(var i=0; i<list.length; i++){
list[i].className = "";
}
while(target.tagName != "LI" && target.tagName == "body"){
target = targt.parentNode;
}
target.className = "big";
}
function initList(){
var outer = document.getElementById("subject");
var list = outer.getElementsByTagName("li");
for(var i=0; i<list.length; i++){
bind(list[i],"mouseover", mouseoverHandler);
}
}
initList();
最后函数执行的时候应该放在 window.onload = function(){ initList()};
function bind(el,eventType, callback){ if(typeof el.addEventListener === "function"){ el.addEventListener(el,eventType, callback,false); }else if(typeof el.attechEvent === "function"){ el.attechEvent("on" + eventType,callback); } } function mouseoverHandler(e){ var target = e.target || e.srcElement; var outer = document.getElementById("subject"); var list = outer.getElementsByTagName("li"); for(var i=0; i<list.length; i++){ list[i].className = ""; } while(target.tagName != "LI" && target.tagName == "body"){ target = targt.parentNode; } target.className = "big"; } function initList(){ var outer = document.getElementById("subject"); var list = outer.getElementsByTagName("li"); for(var i=0; i<list.length; i++){ bind(list[i],"mouseover", mouseoverHandler); } } initList();