Created
February 26, 2020 17:22
-
-
Save accessomnath/5c8022fbc640c249489c9b8e156e5b1b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body> | |
<div class="container"> | |
<h2>Dynamic Tabs</h2> | |
<p>To make the tabs toggleable, add the data-toggle="tab" attribute to each link. Then add a .tab-pane class with a unique ID for every tab and wrap them inside a div element with class .tab-content.</p> | |
<ul class="nav nav-tabs" id="myLinks"> | |
<li class="active"><a data-toggle="tab" href="#home">Home</a></li> | |
<li><a href="#menu1">Menu 1</a></li> | |
<li><a href="#menu2">Menu 2</a></li> | |
<li><a href="#menu3">Menu 3</a></li> | |
</ul> | |
<div class="tab-content" id="myTabs"> | |
<div id="home" class="tab-pane fade in active"> | |
<h1>Form 1</h1> | |
<form> | |
<div class="form-group"> | |
<label for="email">Email:</label> | |
<input type="email" class="form-control" id="email" placeholder="Enter email"> | |
</div> | |
<div class="form-group"> | |
<label for="pwd">Password:</label> | |
<input type="password" class="form-control" id="pwd" placeholder="Enter password"> | |
</div> | |
<div class="checkbox"> | |
<label><input type="checkbox"> Remember me</label> | |
</div> | |
<button type="submit" class="btn btn-default">Submit</button> | |
</form> | |
</div> | |
<div id="menu1" class="tab-pane fade"> | |
<h1>Form 2</h1> | |
<form> | |
<div class="form-group"> | |
<label for="email">Email:</label> | |
<input type="email" class="form-control" id="email" placeholder="Enter email"> | |
</div> | |
<div class="form-group"> | |
<label for="pwd">Password:</label> | |
<input type="password" class="form-control" id="pwd" placeholder="Enter password"> | |
</div> | |
<div class="checkbox"> | |
<label><input type="checkbox"> Remember me</label> | |
</div> | |
<button type="submit" class="btn btn-default">Submit</button> | |
</form> | |
</div> | |
<div id="menu2" class="tab-pane fade"> | |
<h1>Form 3</h1> | |
<form> | |
<div class="form-group"> | |
<label for="email">Email:</label> | |
<input type="email" class="form-control" id="email" placeholder="Enter email"> | |
</div> | |
<div class="form-group"> | |
<label for="pwd">Password:</label> | |
<input type="password" class="form-control" id="pwd" placeholder="Enter password"> | |
</div> | |
<div class="checkbox"> | |
<label><input type="checkbox"> Remember me</label> | |
</div> | |
<button type="submit" class="btn btn-default">Submit</button> | |
</form> | |
</div> | |
<div id="menu3" class="tab-pane fade"> | |
<h1>Form 4</h1> | |
<form> | |
<div class="form-group"> | |
<label for="email">Email:</label> | |
<input type="email" class="form-control" id="email" placeholder="Enter email"> | |
</div> | |
<div class="form-group"> | |
<label for="pwd">Password:</label> | |
<input type="password" class="form-control" id="pwd" placeholder="Enter password"> | |
</div> | |
<div class="checkbox"> | |
<label><input type="checkbox"> Remember me</label> | |
</div> | |
<button type="submit" class="btn btn-default">Submit</button> | |
</form> | |
</div> | |
</div> | |
</div> | |
$("#myTabs form").on('submit',function(e) { | |
e.preventDefault(); | |
var li_count = $('.nav-tabs li').length; | |
var current_active = $('.nav-tabs li.active').index(); | |
if(current_active<li_count){ | |
$('.nav-tabs li.active').next('li').find('a').attr('data-toggle','tab').tab('show'); | |
}else{ | |
alert('Last Step'); | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment