jquery tabs插件
来源:互联网 发布:淘宝省油宝有用吗 编辑:程序博客网 时间:2024/05/01 08:24
写了一个jquery tabs插件,使用事件代理处理事件。
结构层是群里深度讨论得出的最好的结构。
<
dl
id
=
"aaa"
>
<
dt
><
a
>切换卡1</
a
><
a
>切换卡2</
a
><
a
>切换卡3</
a
></
dt
>
<
dd
>内容1</
dd
>
<
dd
>内容2</
dd
>
<
dd
>内容3</
dd
>
</
dl
>
- 切换卡1切换卡2切换卡3
- 内容1
- 内容2
- 内容3
<!doctype html>
<html>
<head>
<title>$.tabs</title>
<style>
.dom_tabs_selected {
background:
#6363c1;
}
</style>
<script src=
"javascripts/jquery.js"
></script>
<script>
$(
function
(){
$.tabs =
function
(obj){
return
(
this
instanceof
$.tabs) ?
this
.init.apply(
this
,arguments) :
new
$.tabs(obj)
}
//主动事件 通过编程触发
//被动事件 由用户的行为触发
$.tabs.prototype = {
init:
function
(obj){
var
that =
this
;
//配置属性
$.extend(
this
,{
selectedClass:
"dom_tabs_selected"
,
tabsSelector:
">dt a"
,
panelsSelector:
">dd"
,
click:$.noop,
selected:0
}, obj || { })
this
.ui = $(obj.selector);
this
.tabs =
this
.ui.find(
this
.tabsSelector);
this
.panels =
this
.ui.find(
this
.panelsSelector);
this
.select(
this
.selected)
this
.tabs.live(
"click"
,
function
(){
var
index = that.tabs.index(
this
);
that._switch.call(that,index)
that.click.call(
this
,index,that);
});
},
_switch:
function
(index){
this
.tabs.removeClass(
this
.selectedClass).eq(index).addClass(
this
.selectedClass);
this
.panels.hide().eq(index).show();
},
select:
function
(index,callback){
index = ~~index;
this
._switch(index);
callback && callback.call(
this
.tabs[index],index,
this
);
},
remove:
function
(index,callback){
index = ~~index;
this
.tabs.eq(index).remove();
this
.panels.eq(index).remove();
callback && callback.call(
this
.tabs[index],index,
this
);
}
}
var
tabs = $.tabs({
selector:
"#aaa"
,
selected:1,
click:
function
(index,instance){
alert(index+
" | "
+
this
.tagName+
" | "
+instance.panels.eq(index).text())
}
});
});
</script>
</head>
<body>
<dl id=
"aaa"
>
<dt><a>切换卡1</a><a>切换卡2</a><a>切换卡3</a></dt>
<dd>内容1</dd>
<dd>内容2</dd>
<dd>内容3</dd>
</dl>
</body>
</html>
- jquery tabs插件
- jQuery--插件tabs
- JQuery Tabs 选项卡插件
- jQuery Tabs插件 (选项卡插件) --推荐
- jQuery插件--实现tabs面板效果
- 【jQuery】选项卡插件——tabs
- jQuery Ui Tabs插件使用问题记录
- 详解jquery插件应用之jquery tabs中文参考手册
- Jquery tabs
- jquery插件ui中tabs实现选择面板效果
- 15 个免费的 CSS jQuery Tabs 插件
- 【JQuery UI】选项卡插件——tabs
- 基于jQuery简单实用的Tabs选项卡插件
- Jquery UI tabs(选项卡)插件和accordion(折叠菜单)插件的示例
- [Jquery Plugin]Jquery Tabs 插件简介-更友好地组织你的页面
- jquery增加tabs
- Jquery ui tabs 使用
- Jquery UI tabs
- LVM管理
- windowxp 下JDK及TOMCAT配置
- 在Ubuntu 建立nfs服务器
- C语言中time_t数据类型详细介绍
- 关于佛学
- jquery tabs插件
- Overcome the Fear of Speaking to Groups
- 编译资源死机 make resgen
- 好久没写文章了
- public 公用继承
- JAVA经典算法40题
- 【Android】滑动屏幕效果GestureDetector、OnGestureListener、ViewFlipper
- 解剖linux内核之内存
- PHP编程问题集锦