本文采用嵌套的ul、li代码实现二级导航菜单,并实现导航菜单栏的背景具有上下滑动的效果,注意此处鼠标悬停效果采用的是mouseenter和mouseleave,这对函数可以保证当鼠标在二级菜单移动时,导航菜单的背景不变化,如果采用mouseover和mouseout,鼠标在二级菜单移动一次,导航菜单背景就会上下滑动一次,用户体验差,大家可以自行修改代码观看效果,现将三部分代码贴入:
-----------------JQuery代码---------------------------
$(function(){
$(".navcon ul li").mouseenter(function(){
$(this).children("a").children(".out").stop(true,true).slideUp();
$(this).children("a").children(".over").stop(true,true).slideDown();
$(this).children("ul").show();
});
$(".navcon ul
li").mouseleave(function(){
$(this).children("a").children(".over").stop(true,true).slideUp();
$(this).children("a").children(".out").stop(true,true).slideDown();
$(this).children("ul&#