用jQuery扩展自写的 UI导航
作者:bea
代码如下: (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);
代码如下:
(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)),小有成就感一把!
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- 使用IE6看老赵的博客 jQuery初探
- jQuery+CSS 实现的超Sexy下拉菜单
- JS与框架页的操作代码
- js限制输入框可输入字节数代码
- JavaScript写的一个自定义弹出式对话框代码
- JavaScript QueryString解析类代码
- 屏蔽Flash右键信息的js代码
- JavaScript学习笔记(十)
- AJAX的跨域与JSONP(为文章自动添加短址的功能)
- 前淘宝前端开发工程师阿当的PPT中有JS技术理念问题
- 20个非常有用的PHP类库 加速php开发
- javascript 特性检测并非浏览器检测
- javascript 构建一个xmlhttp对象池合理创建和使用xmlhttp对象
- extjs 为某个事件设置拦截器
- 利用onresize使得div可以随着屏幕大小而自适应的代码
- javascript 不间断的图片滚动并可点击
- Span元素的width属性无效果原因及解决方案
- javascript实现的基于金山词霸网络翻译的代码
- JQuery 引发两次$(document.ready)事件