<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#tab1">Tab 1</a></li>
<li><a data-toggle="tab" href="#tab2">Tab 2</a></li>
<li><a data-toggle="tab" href="#tab3">Tab 3</a></li>
<li><a data-toggle="tab" href="#tab4">Tab 4</a></li>
</ul>
<div class="tab-content">
<div id="tab1" class="tab-pane fade in active">
<h3>Tab 1</h3>
<p>This is Tab 1</p>
</div>
<div id="tab2" class="tab-pane fade">
<h3>Tab 2</h3>
<p>This is Tab 2</p>
</div>
<div id="tab3" class="tab-pane fade">
<h3>Tab 3</h3>
<p>This is Tab 3</p>
</div>
<div id="tab4" class="tab-pane fade">
<h3>Tab 4</h3>
<p>This is Tab 4</p>
</div>
</div>
</div>
<ul class="pager">
<li><a href="#">Previous</a></li>
<li><a href="#">Next</a></li>
</ul>
</div>
</body>
</html>
您是否知道如何将寻呼机链接到Bootstrap中的标签?寻呼机(上一页和下一页)应该将您从活动标签转到下一个或上一个标签?假设用户在选项卡3上,每个选项卡都有数据字段,当用户填写这些字段时,“下一步”应该允许他继续选项卡4,否则应禁用“下一步”链接。
答案 0 :(得分:0)
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#tab1">Tab 1</a></li>
<li><a data-toggle="tab" href="#tab2">Tab 2</a></li>
<li><a data-toggle="tab" href="#tab3">Tab 3</a></li>
<li><a data-toggle="tab" href="#tab4">Tab 4</a></li>
</ul>
<div class="tab-content">
<div id="tab1" class="tab-pane fade in active">
<h3>Tab 1</h3>
<p>This is Tab 1</p>
<ul class="pager">
<li><a href="#tab2">Next</a></li>
</ul>
</div>
<div id="tab2" class="tab-pane fade">
<h3>Tab 2</h3>
<p>This is Tab 2</p>
<ul class="pager">
<li><a href="#tab1">Previous</a></li>
<li><a href="#tab3">Next</a></li>
</ul>
</div>
<div id="tab3" class="tab-pane fade">
<h3>Tab 3</h3>
<p>This is Tab 3</p>
<ul class="pager">
<li><a href="#tab2">Previous</a></li>
<li><a href="#tab4">Next</a></li>
</ul>
</div>
<div id="tab4" class="tab-pane fade">
<h3>Tab 4</h3>
<p>This is Tab 4</p>
<ul class="pager">
<li><a href="#tab3">Previous</a></li>
</ul>
</div>
</div>
</div>
</div>
</body>
</html>
答案 1 :(得分:0)
使用next()/prev()
和tab('show')
$('.prev').click(function(){
$('.nav-tabs .active').prev().tab('show');//get the next tab and show it
});
$('.next').click(function(){
$('.nav-tabs .active').next().tab('show');
});
&#13;
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#tab1">Tab 1</a></li>
<li><a data-toggle="tab" href="#tab2">Tab 2</a></li>
<li><a data-toggle="tab" href="#tab3">Tab 3</a></li>
<li><a data-toggle="tab" href="#tab4">Tab 4</a></li>
</ul>
<div class="tab-content">
<div id="tab1" class="tab-pane fade in active">
<h3>Tab 1</h3>
<p>This is Tab 1</p>
</div>
<div id="tab2" class="tab-pane fade">
<h3>Tab 2</h3>
<p>This is Tab 2</p>
</div>
<div id="tab3" class="tab-pane fade">
<h3>Tab 3</h3>
<p>This is Tab 3</p>
</div>
<div id="tab4" class="tab-pane fade">
<h3>Tab 4</h3>
<p>This is Tab 4</p>
</div>
</div>
</div>
<ul class="pager">
<li><a href="#" class="prev">Previous</a></li>
<li><a href="#" class="next">Next</a></li>
</ul>
</div>
</body>
</html>
&#13;