<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset="utf-8" />
<title>jquery实现简单的Tab切换菜单</title>
<style type="text/css">
.container {width: 500px; margin: 10px auto;}
ul.tabs {
margin: 0;
padding: 0;
float: left;
list-style: none;
height: 32px;
border-bottom: 1px solid #999;
border-left: 1px solid #999;
width: 100%;
}
ul.tabs li {
float: left;
margin: 0;
padding: 0;
height: 31px;
line-height: 31px;
border: 1px solid #999;
border-left: none;
margin-bottom: -1px;
background: #e0e0e0;
overflow: hidden;
position: relative;
}
ul.tabs li a {
text-decoration: none;
color: #000;
display: block;
font-size: 1.2em;
padding: 0 20px;
border: 1px solid #fff;
outline: none;
}
ul.tabs li a:hover {
background: #ccc;
}
html ul.tabs li.active, html ul.tabs li.active a:hover {
background: #fff;
border-bottom: 1px solid #fff;
}
.tab_container {
border: 1px solid #999;
border-top: none;
clear: both;
float: left;
width: 100%;
background: #fff;
-moz-border-radius-bottomright: 5px;
-khtml-border-radius-bottomright: 5px;
-webkit-border-bottom-right-radius: 5px;
-moz-border-radius-bottomleft: 5px;
-khtml-border-radius-bottomleft: 5px;
-webkit-border-bottom-left-radius: 5px;
}
.tab_content {
padding: 20px;
font-size: 1.2em;
}
.tab_content h2 {
font-weight: normal;
padding-bottom: 10px;
border-bottom: 1px dashed #ddd;
font-size: 1.8em;
}
.tab_content h3 a{
color: #254588;
}
.tab_content img {
float: left;
margin: 0 20px 20px 0;
border: 1px solid #ddd;
padding: 5px;
}
</style>
<script type="text/javascript" src="jquery-1.8.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
//初始化操作
$(".tab_content").hide(); //隐藏所有div
$("ul.tabs li:first").addClass("active").show(); // 第一个li选中
$(".tab_content:first").show(); //显示首个tab
//点击事件
$("ul.tabs li").click(function() {
$("ul.tabs li").removeClass("active"); //移除active样式
$(this).addClass("active"); //为选中li添加active样式
$(".tab_content").hide(); //隐藏所有tab content
var activeTab = $(this).find("a").attr("href");
$(activeTab).fadeIn();
return false;
});
});
</script>
</head>
<body>
<div id="main_demo">
<div align="center"><h2><a href="http://www.freejs.net/article_tabbiaoqian_29.html">Jquery tab 选项卡</a></h2></div>
<div class="container">
<ul class="tabs">
<li class="active"><a href="#tab1">我的博客</a></li>
<li><a href="#tab4">UI交流</a></li>
</ul>
<div class="tab_container">
<div id="tab1" class="tab_content" style="display: block; ">
<h3><a href="http://blog.csdn.net/lwllai">左右为南的专栏</a></h3>
<p id="">ASP.NET MVC、EXT.NET、Kendo UI、Easy UI、WPF、WCF等;web前端交流:JavaScript、Jquery、HTML5、CSS、jquery mobile;数据库交流:SQLSERVER、Mysql、ORACLE
<br><a target="_blank" href="http://shang.qq.com/wpa/qunwpa?idkey=e5514b489054c382f0150be772d03dd96eca83d324bf376d81753a8dfa9a3ed2"><img border="0" src="http://pub.idqqimg.com/wpa/images/group.png" alt=".NET Web交流群" title=".NET Web交流群"></a>QQ群:364125779</p>
</div>
<div id="tab4" class="tab_content" style="display: none; ">
<h2>kendo UI</h2>
<h3><a href="http://blog.csdn.net/lwllai/article/details/45965545">kendoGrid单击、双击事件绑定并获取当前行数据 </a></h3>
<p> <a target="_blank" href="http://shang.qq.com/wpa/qunwpa?idkey=e5514b489054c382f0150be772d03dd96eca83d324bf376d81753a8dfa9a3ed2"><img border="0" src="http://pub.idqqimg.com/wpa/images/group.png" alt=".NET Web交流群" title=".NET Web交流群"></a>.NET Web交流群:364125779</p>
</div>
</div>
</div>
<br><br>
</div>
</body>
</html>