这是一个使用导航栏作为选项卡的示例代码。
<!DOCTYPE html>
<html>
<head>
<title>My Page</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" />
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script>
var prevSelection = "tab1";
$("#navbar ul li").live("click",function(){
var newSelection = $(this).children("a").attr("data-tab-class");
$("."+prevSelection).addClass("ui-screen-hidden");
$("."+newSelection).removeClass("ui-screen-hidden");
prevSelection = newSelection;
});
</script>
<script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script>
<style>
.tab-content{
width:100%;
height:250px;
background-color:white;
border-bottom-left-radius:0.5em;
border-bottom-right-radius:0.5em;
}
.tab-content>div{
padding:5px;
}
</style>
</head>
<body>
<div data-role="page">
<div data-role="header">
<h1>My Title</h1>
</div><!-- /header -->
<div data-role="content">
<div data-role="navbar" id="navbar">
<ul>
<li><a href="#" class="ui-btn-active" data-tab-class="tab1">Tab1</a></li>
<li><a href="#" data-tab-class="tab2">Tab2</a></li>
<li><a href="#" data-tab-class="tab3">Tab3</a></li>
<li><a href="#" data-tab-class="tab4">Tab4</a></li>
</ul>
</div>
<div class="tab-content">
<div class="tab1">
Tab1
</div>
<div class="tab2 ui-screen-hidden">
Tab2
</div>
<div class="tab3 ui-screen-hidden">
Tab3
</div>
<div class="tab4 ui-screen-hidden">
Tab4
</div>
</div>
</div><!-- /content -->
</div><!-- /page -->
</body>
</html>
一个演示 - http://jsfiddle.net/m8wQM/
让我知道它是否有帮助。