网站下拉菜单

----------代码---------
<style type="text/css">
<!--
#Layer1 {
position:absolute;
width:46px;
height:81px;
z-index:1;
left: 16px;
top: 37px;
}
#Layer2 {
position:absolute;
width:87px;
height:79px;
z-index:2;
left: 76px;
top: 34px;
}
#Layer3 {
position:absolute;
width:87px;
height:79px;
z-index:2;
left: 197px;
top: 36px;
}
-->
</style>
</head>
<script>
function ycang(id){
for(i=1;i<=3;i++){
if(eval("id" + i)!=id){
eval("Layer" + i + ".style.display=\"none\";");
//document.getElementById("bg"+i).style.backgroundImage = "url('换背景图片1')";换背景图片
}else{
eval("Layer" + i + ".style.display=\"\";");
//document.getElementById("bg"+i).style.backgroundImage = "url('换背景图片2')";换背景图片
}
}
}
</script>
<body>
<a href="" id="id1" onmouseover="javascript:ycang(this);">asas</a><a href="" id=id2 onmouseover="javascript:ycang(this);">sdfsdfsdf</a><a href="" id=id3 onmouseover="javascript:ycang(this);">sdfsdfsdf</a>
<div id="Layer1" style="display: none">11</div>
<div id="Layer2" style="display: none">22</div>
<div id="Layer3" style="display: none">33</div>
</body>



以前都是用别人的代码的。一,乱,二,难改。今天心情好自己花了5分钟自己写了一个,感觉代码简练又实用 <!--v:3.2-->

你可能感兴趣的:(JavaScript,css)