Heim  >  Artikel  >  Web-Frontend  >  jquery 经典动画菜单效果代码_jquery

jquery 经典动画菜单效果代码_jquery

WBOY
WBOYOriginal
2016-05-16 18:35:551033Durchsuche
复制代码 代码如下:

body
{
font-size:12px;
}
.menuBox
{
width:50%;
height:auto;
margin:0 auto;
}
.menuBox ul
{
margin:0px;
padding:0px;
}
.menuBox ul li
{
float:left;
display:block;
width:18%;
height:30px;
line-height:25px;
list-style:none;
margin-right:1px;
}
.menuBox ul li a
{
display:block;
width:100%;
height:100%;
background-color:Black;
color:White;
text-decoration:none;
text-align:center;
}
.menuBox ul li a:hover
{
display:block;
width:100%;
height:100%;
background-color:Silver;
color:Red;
text-decoration:none;
}
.menuSelected
{
display:block;
width:100%;
height:100%;
background-color:Silver;
color:Red;
text-decoration:none;
}
.chideMenuForShow
{
width:200px;
position:absolute;
height:auto;
border:1px solid #ccc;
float:right;
background-color:Silver;
}

HTML代码
复制代码 代码如下:



Javascript代码
复制代码 代码如下:

/*
menu for javascript
author:mr·zhong
date:2010-01-25
*/
/*判断当前子菜单显示或隐藏*/
var MenuShowOrHide = false;
$(function(){
SetMenuID();
BindMenuHoverEval();
BindChideMenuHoverEval();
});
/*
设置主、子菜单按钮ID
*/
function SetMenuID(){
var id = 1;
$('#ul_menu a').each(function(){
$(this).attr("id","a_" + id);
var chideObj = $(this).next();
chideObj.attr("id","ChideMenu_a_" + id);
chideObj.hide();
id++;
});
}
/*
设置菜单颜色样式
*/
function SetMenuColor(menuID,isSelected){
if(isSelected) $("#" + menuID).addClass("menuSelected");
else $("#" + menuID).removeClass("menuSelected");
}
/*
设置子菜单显示或隐藏
*/
function ShowOrHideChideMenu(menuID,isShow){
var obj = $("#" + menuID);
if(isShow)
{
obj.slideDown("slow");
}
else obj.hide("slow");
}
/*
绑定主菜单鼠标事件
*/
function BindMenuHoverEval(){
$("#ul_menu a").each(function(){
$(this).hover(function(){
ShowOrHideChideMenu("ChideMenu_" + $(this).attr("id"),true);
MenuShowOrHide = true;
},function(){
setTimeout('Hide(ChideMenu_' + $(this).attr("id") +')',500);
});
});
}
/*
绑定子菜单鼠标事件
*/
function BindChideMenuHoverEval(){
$("#ul_menu .chideMenuForShow").each(function(){
$(this).hover(function(){
MenuShowOrHide = true;
},function(){
MenuShowOrHide = false;
Hide($(this).attr("id"));
});
});
}
/*
隐藏子菜单
*/
function Hide(id){
if(!MenuShowOrHide) ShowOrHideChideMenu(id,false);
}

下载地址:http://www.jb51.net/jiaoben/24160.html
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn