将onmouseover改成onclick为什么实现不了点击切换?
function $(id){
return typeof id==='string'?document.getElementById(id):id;
}
window.onload=function(){
var titles=$('menu').getElementsByTagName('li');
contents=$('notice').getElementsByTagName('div');
if (titles.length!=contents.length)
return;
for (var i = 0; i < titles.length; i++) {
titles[i].id=i;
titles[i].onmouseover=function(){
for (var j = 0; j < titles.length; j++) {
titles[j].className="";
contents[j].style.display="none";
}
this.className="active";
contents[this.id].style.display="block";
}
}
}