使用jQuery+css实现选项卡切换功能
2015-08-17 14:30
761 查看
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>HTML+jQuery+css 选项卡切换更能</title> <meta name="keywords" content="HTML+jQuery+css 选项卡切换更能<" /> <meta name="description" content="HTML+jQuery+css 选项卡切换更能<" /> <style type="text/css"> body,ul,li{ margin: 0;padding: 0; font: 12px normal "宋体", Arial, Helvetica, sans-serif; list-style: none; } a{ text-decoration: none;color: #000; font-size: 14px; } #tabbox{ width:1000px; overflow:hidden; margin:0 auto; } .tab_conbox{ border: 1px solid #999;border-top: none; } .tab_con{ display:none; } .tabs{ height: 32px;border-bottom:1px solid #999;border-left: 1px solid #999; width: 100%; } .tabs li{ height:31px;line-height:31px; float:left;border:1px solid #999; border-left:none; margin-bottom: -1px;background: #e0e0e0; overflow: hidden;position: relative; } .tabs li a { display: block;padding: 0 20px; border: 1px solid #fff;outline: none; } .tabs li a:hover { background: #ccc; } .tabs .thistab,.tabs .thistab a:hover{ background: #fff;border-bottom: 1px solid #fff; } .tab_con { padding:12px;font-size: 14px; line-height:175%; } </style> <script src="http://lib.sinaapp.com/js/jquery/1.4.2/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { jQuery.jqtab = function(tabtit,tabcon) { $(tabcon).hide(); $(tabtit+" li:first").addClass("thistab").show(); $(tabcon+":first").show(); $(tabtit+" li").click(function() { $(tabtit+" li").removeClass("thistab"); $(this).addClass("thistab"); $(tabcon).hide(); var activeTab = $(this).find("a").attr("tab"); $("#"+activeTab).fadeIn(); return false; }); }; /*调用方法如下:*/ $.jqtab("#tabs",".tab_con"); }); </script> </head> <body> <div id="tabbox"> <ul class="tabs" id="tabs"> <li><a tab="tab1">选项卡1</a></li> <li><a tab="tab2">选项卡2</a></li> <li><a tab="tab3">选项卡3</a></li> <li><a tab="tab4">选项卡4</a></li> </ul> <ul class="tab_conbox"> <li id="tab1" class="tab_con"> <p>总要说点什么.又不知道说什么! Hello world !</P> <p>在辽宁抚顺新宾有一个帅哥,很帅很帅很帅很帅很帅很帅很帅很帅很帅很帅...... 的帅哥,他叫SunZhenYang \(^o^)/~</p> </li> <li id="tab2" class="tab_con"> <p>总要说点什么.又不知道说什么! Hello world !</P> <p>在辽宁抚顺新宾有一个帅哥,很帅很帅很帅很帅很帅很帅很帅很帅很帅很帅...... 的帅哥,他叫SunZhenYang \(^o^)/~</p> </li> <li id="tab3" class="tab_con"> <p>总要说点什么.又不知道说什么! Hello world !</P> <p>在辽宁抚顺新宾有一个帅哥,很帅很帅很帅很帅很帅很帅很帅很帅很帅很帅...... 的帅哥,他叫SunZhenYang \(^o^)/~</p> </li> <li id="tab4" class="tab_con"> <p>总要说点什么.又不知道说什么! Hello world !</P> <p>在辽宁抚顺新宾有一个帅哥,很帅很帅很帅很帅很帅很帅很帅很帅很帅很帅...... 的帅哥,他叫SunZhenYang \(^o^)/~</p>。 </li> </ul> </div> </body> </html>
相关文章推荐
- jquery动感漂浮导航菜单代码分享
- jQuery 控制表单和表格
- jQuery--样式的操作
- 【JQuery的选择器】
- jquery基础精华05
- jquery基础精华04(01)
- jquery基础精华03
- jquery基础精华02
- jquery基础精华01
- jquery.seat-charts选座
- 创建一个鼠标停留显示悬浮二维码效果
- jquery过滤器之:contains()、.filter()
- JQuery中对Select的option项的添加、删除、取值
- jQuery EasyUI combobox在datagrid中的级联依赖
- jquery实现动静态条形统计图
- jQuery手机触屏左右滑动切换栏目和焦点图
- jQuery获取多种input值的方法
- jquery-validation 学习总结
- jQuery笔记:checkbox
- jquery创建动态的div