jquery实现无限分级横向导航菜单的方法

2020-05-24 21:40:53易采站长站整理

本文实例讲述了jquery实现无限分级横向导航菜单的方法。分享给大家供大家参考。具体实现方法如下:

1. jquery插件版本代码如下:
(function($){
    $.fn.extend({
        droplinemenu: function(configs) {
            var configs = $.extend({               
                over: 200,
                out: 100,
                rightdown:’css/down.gif’
            },configs||{});
            this.find(“>ul”).addClass(“dropmenu”);
            this.find(“ul li:has(ul)”).addClass(‘hasmenu’).find(“>a”).append(“<img class=’downarrowclass’ src='”+configs.rightdown+”‘>”);
            var currentobj;
            return $(‘li.hasmenu’).hover(function(){                
                if ($.browser.msie) {//清除ie下生成的overflow:hidden
                    $(this).parent(“ul”).css({‘overflow’: ‘visible’});
                }
                $(this).find(“>ul”).stop(true, true).css(‘top’,$(this).height()).slideDown(configs.over);
            },function(){  
                $(this).find(“>ul”).stop(true, true).slideUp(configs.out);
            });
        }
    });
})(jQuery);
2. 样式代码
* {margin:0;padding:0}
.droplinebar{
     position: absolute;
    z-index: 20;
    width: 700px;
}
.droplinebar ul.dropmenu {