61,112
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
#one{
color:red;
border:#FF0000 1px solid;
font-size:20px;
display:none;/*设置默认隐藏,也就是加载完页面也不显示*/
}
</style>
<script type="text/javascript">
function init(){ //这个代码可以让隐藏的代码显示出来.里面的"one"可以改成别的,但要注意CSS和div id里面的one,必须一致
var x = document.getElementById("one").style.display="block";
}
function out(){ //假如鼠标移开,one所属的div会再次隐藏.
var y = document.getElementById("one").style.display="none";
}
</script>
</head>
<!--因为还没学JQ,只能写这样了,你看着改一下吧。-->
<body>
<div id="top" onmouseover="init()" onmouseout="out()"><!--后面的两个分别是调用的JS方法,名字可以改,但注意对应-->
显示 <!--可作为顶级菜单使用-->
</div>
<div id="one"><!--默认隐藏的块-->
顶级菜单.
<div class="two">
二级菜单
</div>
<div class="there">
三级菜单
</div>
</div>
</body>
</html>