鼠标滑过,
很简单不用Js,也不用大量代码,关键是样式 里加一句就行:
li:hover {background:#4949d2; border-radius: 8px;}
li {float:left;margin-right:25px;padding:5px}
.active {background-color:red}
.hover {background-color:blue;color:white}
.normal {background-color:white;color:black}
首页二页三页var navbar=document.getElementById("navbar");
var items=navbar.getElementsByTagName("li");
var curactiveitem="first";
for(i=0;iitems[i].onmouseover=onhover;
items[i].onclick=onactive;
}
function onhover(){
for(i=0;iif(items[i].id!=curactiveitem){
items[i].className="normal";
}
}
if(this.id!=curactiveitem){this.className="hover";}
}
function onactive(){
document.getElementById(curactiveitem).className="normal";
this.className="active";
curactiveitem=this.id;
}
标签:滑过,鼠标