欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  web前端

用jQuery扩展自写的 UI导航_jquery

程序员文章站 2022-04-23 10:32:31
...
复制代码 代码如下:

(function($){
$.navs=function(){
return $('#top_menu_bar > li').each(function(){
$(this).hover(
function(){
$(this).find('ul:eq(0)').show();
},
function(){
$(this).find('ul:eq(0)').hide();
}
);
});
};
})(jQuery);

上面是直接定义属性。下面是种常见的方法:
复制代码 代码如下:

jQuery.extend({
navs:function(){
return $('#top_menu_bar > li').each(function(){
$(this).hover(
function(){
$(this).find('ul:eq(0)').show();
},
function(){
$(this).find('ul:eq(0)').hide();
}
);
});
}
});

调用测试下:
$.navs();
两年前的野心今天终于实现了(噢,这是导航,不是页签(tabs)),小有成就感一把!
相关标签: jQuery UI导航