Reputation: 109
First thank you for reading this, and i would like to apologize if this is a duplicate question.
I am working with bootstrap, and I like to use the Dynamic Pills
I got every working fine like the example on w3schools:
http://www.w3schools.com/bootstrap/tryit.asp?filename=trybs_pills_dynamic&stacked=h
I was wondering if it is possible to have an autoloop in jQuery/javascript that it will automatically go through the tabs
I tried to use the following for just to activate 1 off the tabs when the loading the page
<script type="text/javascript">
$(window).load(function(){
$('#menu3').pills("show");
});
</script>
<title>Bootstrap Case</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2>Dynamic Pills</h2>
<ul class="nav nav-pills">
<li class="active"><a data-toggle="pill" href="#home">Home</a></li>
<li><a data-toggle="pill" href="#menu1">Menu 1</a></li>
<li><a data-toggle="pill" href="#menu2">Menu 2</a></li>
<li><a data-toggle="pill" href="#menu3">Menu 3</a></li>
</ul>
<div class="tab-content">
<div id="home" class="tab-pane fade in active">
<h3>HOME</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
<div id="menu1" class="tab-pane fade">
<h3>Menu 1</h3>
<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
<div id="menu2" class="tab-pane fade">
<h3>Menu 2</h3>
<p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam.</p>
</div>
<div id="menu3" class="tab-pane fade">
<h3>Menu 3</h3>
<p>Eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.</p>
</div>
</div>
</div>
</body>
</html>
Help would be really appreciated, because I am really a noob!
Upvotes: 2
Views: 941
Reputation: 141
Try something like:
function changeTags() { # your code to change the tags } setTimeout(changeTags(), 2000);
This would be harder to implement. Maybe a better and much easier would be to modify and use Carousel from Bootstrap
Upvotes: 0
Reputation: 469
if you want to loop through the nav-pills use the setInterval
https://jsfiddle.net/fq80o54c/
Upvotes: 2