Home > Web Front-end > JS Tutorial > jquery classic animated menu effect code_jquery

jquery classic animated menu effect code_jquery

WBOY
Release: 2016-05-16 18:35:55
Original
1109 people have browsed it
复制代码 代码如下:

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
*/
/*Determine whether the current submenu is displayed or hidden* /
var MenuShowOrHide = false;
$(function(){
SetMenuID();
BindMenuHoverEval();
BindChideMenuHoverEval();
});
/*
Set the main and submenu button IDs
*/
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 ;
});
}
/*
Set menu color style
*/
function SetMenuColor(menuID, isSelected){
if(isSelected) $("#" menuID).addClass("menuSelected");
else $("#" menuID).removeClass("menuSelected");
}
/*
Set the submenu to show or hide
*/
function ShowOrHideChideMenu(menuID,isShow){
var obj = $("#" menuID);
if(isShow)
{
obj.slideDown("slow");
}
else obj.hide("slow");
}
/*
Bind the main menu mouse event
*/
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);
});
});
}
/*
Bind submenu mouse events
*/
function BindChideMenuHoverEval(){
$("#ul_menu .chideMenuForShow").each(function(){
$(this).hover(function(){
MenuShowOrHide = true;
}, function(){
MenuShowOrHide = false;
Hide($(this).attr("id"));
});
});
}
/*
Hide submenu
*/
function Hide(id){
if(!MenuShowOrHide) ShowOrHideChideMenu(id,false);
}

Download address :http://www.jb51.net/jiaoben/24160.html
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template