Assalamu'alaikum wr wb,
kali ini saya akan share bagaimana Cara menuju ke spesifik tab di bootstrap,
berikut ini syntaxnya.
Disini defaultnya aktif pada tab 1, namun diubah menjadi tab 2 yang aktif melalui javascript.
<link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<style type="text/css">
/* Latest compiled and minified CSS included as External Resource*/
/* Optional theme */
@import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');
body {
margin: 10px;
}
</style>
<ul class="nav nav-tabs">
<li class="active"><a href="#tab1" data-toggle="tab">Tab1</a></li>
<li><a href="#tab2" data-toggle="tab">Tab2</a></li>
</ul>
<div class="tab-content" id="tabs">
<div class="tab-pane active" id="tab1">...Tab1 Content...</div>
<div class="tab-pane" id="tab2">...Tab2 Content...</div>
</div>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<script type="text/javascript" src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script type="text/javascript">
function activaTab(tabID)
{
$('.nav-tabs a[href="#' + tabID + '"]').tab('show');
};
activaTab('tab2');
</script>
Semoga bermanfaat.
http://pangeran-it.blogspot.co.id/
Cara menuju ke spesifik tab di bootstrap
Reviewed by Syawaluddin Amin, S.Kom
on
September 18, 2017
Rating:
Tidak ada komentar: