JavaScript preprocessors can help make authoring JavaScript easier and more convenient. For instance, CoffeeScript can help prevent easy-to-make mistakes and offer a cleaner syntax and Babel can bring ECMAScript 6 features to browsers that only support ECMAScript 5.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
HTML Settings
Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
<body>
<div class="container-fluid">
<h2>Tabs in jQuery.</h2>
<h4>They switch</h4>
<div class="row">
<div class="tab-panels col-xs-12">
<!-- creating tabs here -->
<ul class="tabs">
<li rel="panel-1" class="active"> Tab 1</li>
<li rel="panel-2"> Tab 2</li>
<li rel="panel-3"> Tab 3</li>
<li rel="panel-4"> Tab 4</li>
</ul>
<div id="panel-1" class="panel active">
<p> 1. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum </p>
</div>
<div id="panel-2" class="panel">
<p > 2. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
</div>
<div id="panel-3" class="panel">
<p> 3. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
</div>
<div id="panel-4" class="panel">
<p> 4. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum </p>
</div>
</div>
</div> <!-- row ends here -->
</div> <!--container end here -->
</body>
body {
font: 1.5em "Tahoma", san-serif;
color: white;
padding:1em;
background-color: #301;
}
.tab-panels ul {
margin: 0;
padding: 0;
}
.tab-panels ul li {
list-style-type: none;
display: inline-block;
background: #c55;
margin: 0;
padding: .5em 1.5em;
border-radius: .5em .5em 0 0;
color: #fff;
font-weight: 50;
cursor: pointer;
}
.tab-panels ul li:hover {
color: #fff;
background: #b20;
}
.tab-panels ul li.active {
color: #fff;
background: #b20;
}
.tab-panels .panel {
display:none;
background: white;
color: black;
padding: 1.5em;
border-radius: 0 0 .8em .8em;
}
.tab-panels .panel.active {
display:block;
}
// Note to self: make it smarter
$(document).ready(function() {
// Step -1 : Create an event for click to each panel
$('.tab-panels .tabs li').on('click', function(){ //$-1 starts
$('.tab-panels .tabs .active').removeClass('active'); // removes active class from li that was clicked
$(this).addClass('active'); // adding the active class to this so switching tabs would switch the active class to the current li that was clicked and remove active class from previous li
var paneltoshow = $(this).attr('rel'); // storing and later on referencing li that was clicked using rel attribute. You can use anything else with say, data-yourIdname instead of rel. Upto you.
//alert(paneltoshow);
$('.tab-panels .panel.active').slideUp('100', function(){
$(this).removeClass('active'); //console.log(this);
$('#'+paneltoshow).delay('100').slideDown(function () {
$(this).addClass('active'); //console.log(this);
});
});
}); //$-1 ends
});
/* ready ends here */
Also see: Tab Triggers