<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gbk" />
<title>jquery tab选项卡切换实例</title>
<link href="img/saas.css教程" rel="stylesheet" type="text/css" />
<script src="js/jquery.js"></script>
<script src="js/jquery.tab0.9.js"></script>
<script language="网页特效" src="js/jquery.mask.js"></script>
</head>
<body>
功能描述:
1、支持自定义html内容
2、支持ajax加载内容
3、回调函数
<br />
滑动demo
<div id="tab_list" style="width:700px">
</div>
普通demo
<div id="tab_list_n">
</div>
ajax demo
<div id="tab_list_a">
</div>
动态添加自动显示滑动 demo <input type="button" id="addtab" value="add">
<div id="tab_list_add">
</div>
动态添加不显示滑动 demo <input type="button" id="addtabn" value="add">
<div id="tab_list_addn">
</div>
</body>
</html>
<script>
$(function(){$("#tab_list").tab({items:[
{title:'tab1',closed:true,icon:'',html:'test1',load:'',callback:function(){}},
{title:'tab22222222',closed:true,icon:'',html:'test2',load:'',callback:function(){alert('click tab2');}},
{title:'tab3',closed:true,icon:'',html:'test3',load:'',callback:function(){}},
{title:'tab4',closed:true,icon:'',html:'test4',load:'',callback:function(){}},
{title:'tab5',closed:true,icon:'',html:'test5',load:'',callback:function(){}},
{title:'tab6',closed:true,icon:'',html:'test6',load:'',callback:function(){}},
{title:'tab7',closed:true,icon:'',html:'test7',load:'',callback:function(){}},
{title:'tab8',closed:true,icon:'',html:'test8',load:'',callback:function(){}},
{title:'tab9',closed:true,icon:'',html:'test9',load:'',callback:function(){}},
{title:'tab10',closed:true,icon:'',html:'test10',load:'',callback:function(){}},
{title:'tab11',closed:true,icon:'',html:'test11',load:'',callback:function(){}},
{title:'tab12',closed:true,icon:'',html:'test12',load:'',callback:function(){}},
{title:'tab13',closed:true,icon:'',html:'test13',load:'',callback:function(){}},
{title:'tab14',closed:true,icon:'',html:'test14',load:'',callback:function(){}},
{title:'tab15',closed:true,icon:'',html:'test15',load:'',callback:function(){}},
{title:'tab16',closed:true,icon:'',html:'test16',load:'',callback:function(){}}
],
width:500,
height:100,
tabcontentwidth:500,
tabwidth:66,
tabheight:25,
tabhtml:'一般用于说明的区域 <img src="img/i_min.gif" type="min"/> <img src="img/i_normal.gif" type="normal" class=""/> <img src="img/i_max.gif" type="max" class=""/>'
});
$("#tab_list_n").tab({items:[
{title:'tab1',closed:true,icon:'',html:'test1',load:'',callback:function(){}},
{title:'tab2',closed:true,icon:'',html:'test2',load:'',callback:function(){}},
{title:'tab3',closed:true,icon:'',html:'test3',load:'',callback:function(){}},
{title:'tab13',closed:true,icon:'',html:'test13',load:'',callback:function(){}},
{title:'tab14',closed:true,icon:'',html:'test14',load:'',callback:function(){}},
{title:'tab15',closed:true,icon:'',html:'test15',load:'',callback:function(){}},
{title:'tab16',closed:true,icon:'',html:'test16',load:'',callback:function(){}}
],
tabscroll:false,
width:500,
height:100,
tabcontentwidth:498,
tabwidth:66,
tabheight:25
});
$("#tab_list_a").tab({items:[
{title:'tab1',closed:true,icon:'',html:'',load:'1.html',callback:function(){}},
{title:'tab2',closed:true,icon:'',html:'test2',load:'',callback:function(){}},
{title:'tab3',closed:true,icon:'',html:'test3',load:'',callback:function(){}},
{title:'tab13',closed:true,icon:'',html:'test13',load:'',callback:function(){}},
{title:'tab14',closed:true,icon:'',html:'test14',load:'',callback:function(){}},
{title:'tab15',closed:true,icon:'',html:'test15',load:'',callback:function(){}},
{title:'tab16',closed:true,icon:'',html:'test16',load:'',callback:function(){}}
],
tabscroll:false,
width:500,
height:100,
tabcontentwidth:498,
tabwidth:66,
tabheight:25
});
var o=$("#tab_list_add").tab({items:[
{title:'tab1',closed:true,icon:'',html:'',load:'1.html',callback:function(){}}
],
tabscroll:false,
width:500,
height:100,
tabcontentwidth:498,
tabwidth:66,
tabheight:25
});
$('#addtab').click(function(){
o.newtab({title:'tab1',closed:true,icon:'',html:'',load:'1.html',callback:function(){}});
});
var oo=$("#tab_list_addn").tab({items:[
{title:'tab1',closed:true,icon:'',html:'',load:'1.html',callback:function(){}}
],
tabscroll:false,
width:500,
height:100,
tabcontentwidth:498,
tabwidth:66,
tabheight:25
});
$('#addtabn').click(function(){
oo.addtab({title:'tab1',closed:true,icon:'',html:'',load:'1.html',callback:function(){}});
});
});
</script>
源码下载地址
http://down.111cn.net/down/code/jquery/2010/0907/20677.html