var doms = document.getElementsByTagName('tr');
function show_color(where) {
this.tagName ? where = this : null
where.style.backgroundColor = "red";
}
function hide_color(where) {
this.tagName ? where = this : null
where.style.backgroundColor = "green";
}
function for_ie(where,how) {
return function() {
how(where);
}
}
for (var i = 0; i < doms.length; i++) {
try {
doms[i].addEventListener('mouSEOver',show_color,false);
doms[i].addEventListener('mouSEOut',hide_color,false);
} catch (e) {
doms[i].attachEvent('onmouSEOver',for_ie(doms[i],show_color));
doms[i].attachEvent('onmouSEOut',hide_color));
}
}
在绑定多个相同的事件的时候,前两种方法会产生覆盖,而第三中方法则会同时执行多个事件。
(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!