使用jquery 简单实现下拉菜单

2020-05-22 16:18:53易采站长站整理

        $(“#” + hideDivId).show(); 
        $(“#” + hideDivId).css(“left”, left); 
        $(“#” + hideDivId).css(“top”, top + height); 
    }, function() { 
        // 将原来的菜单隐藏 
        $(“.display”).hide(); 
    }); 

/**
 * 下拉菜单绑定事件
 */ 
function initSubMenuHover() { 
    $(“.display”).hover(function() { 
        $(this).show(); 
    }, function() { 
        $(this).hide(); 
    }); 

/**
 *  下拉菜单改变颜色
 */ 
function initSubMenuLiHover() { 
    $(“.redli”).hover(function() { 
        $(this).addClass(“redcolor”); 
    }, function() { 
        $(this).removeClass(“redcolor”); 
    }); 

效果如下:

小伙伴们使用的时候自己美化下,自由扩展下就可以用到自己的项目中了,我这里仅仅是简单做了点样式而已。