样式:
< style type="text/css">
*{ margin:0px auto; padding:0px}
#wai{ width:150px; height:300px;}
.list{ width:150px; height:40px; text-align:center; line-height:40px; vertical-align:middle; color:white; border:1px solid white;}
.list:hover{ cursor:pointer; padding: 0px 1em !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.8em !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: nowrap !important; background: none rgb(244, 244, 244) !important;"></ style >
< body >< br >
< div id="wai">
< div class="list" onclick="xuan(this)" onmouseover="bian(this)" onmouseout="huifu()">淄博</ div >
< div class="list" onclick="xuan(this)" onmouseover="bian(this)" onmouseout="huifu()">张店</ div >
< div class="list" onclick="xuan(this)" onmouseover="bian(this)" onmouseout="huifu()">桓台</ div >
</ div >
</ body >
< script type="text/javascript">
function xuan(d)
{
//清原来的颜色
var list = document.getElementsByClassName("list");
for(var i=0;i< list.length ;i++)
{
list[i].removeAttribute("bs");
list[i].style.backgroundColor = "#66F";
}
//选
d.setAttribute("bs",1);
d.style.backgroundColor = "#00C";
}
function bian(d)
{
//清
var list = document.getElementsByClassName("list");
for(var i=0;i<list.length;i++)
{
if(list[i].getAttribute("bs")!="1")
{
list[i].style.backgroundColor = "#66F";
}
}
//选
d.style.backgroundColor = "#00C";
}
function huifu()
{
var list = document.getElementsByClassName("list");
for(var i=0;i<list.length;i++)
{
if(list[i].getAttribute("bs")!="1")
{
list[i].style.backgroundColor = "#66F";
}
}
}
</script>
|