日期:2014-05-16  浏览次数:20393 次

JS抽屉式三级菜单应用鼠标移动时显示
功能实现,但要应用到项目中还是要修改些的,样式最少要修改
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>Untitled Document</title>
  <script src="./js/jquery-1.4.2.js" type=text/javascript></script>
 
   <style type="text/css">
ul {
padding: 0;
margin: 0;
list-style: none;
}
li {
float: left;
width: 160px;
}
li ul {
display: none;
top: 20px;
}
li:hover ul, li.over ul {
display: block;


}
.two ul{

  overflow: visible;
display: block;
height: 66px;
z-index: 128;
  opacity: 1;


}
.two ul li{
overflow: hidden;
display: block;
height: 0px;
z-index: 60;
  opacity: 0.0151515;
display:none;
}
ul li a{
display:block;
font-size:12px;
border: 1px solid #ccc;
padding:3px;
text-decoration: none;
color: #777;
}
ul li a:hover{
background-color:#f4f4f4;
}
   .level3
        {
         margin:0;padding:0;position:absolute;
         top:37px;
         left:170px;
         display:none;
         }
        .level3 li
        {
         margin:0;
         padding:0;
         display:block;
         border:solid 1px red;
         }
</style>
<script type="text/javascript">
  $(document).ready(function ()
        {
        //二级菜单和三级菜单隐藏,并且加上isopen 为false的属性
         $('.level2').attr('isopen','false');
         $('.level3').attr('isopen','false');
        
         //一级菜单鼠标经过时
         $('.level1>li').mouseover(
            function ()
         {   //如果该一级菜单下的二级菜单的isopen为false
           if($(this).children(".level2").attr('isopen')=='false')
             {
             //所有该一级菜单下”之外“的二级菜单隐藏,加上isopen为false
             $(".level2:not($(this).children('.level2'))").attr('isopen','false').slideUp("fast");
             //所有三级菜单隐藏,加上isopen为false
             $(".level3").attr('isopen','false').slideUp("fast");
            
             //该一级菜单下的二级菜单弹出,加上isopen为true