I'm having trouble with the tabs in my page. When I click on each tab, the content doesn't display correctly. Here is my code:
<div class="w470px exam" style="border: 1px solid #ddd; margin-top: 30px;">
<ul id="myTab" class="nav nav-tabs nav-justified">
<li class="active"><a href="#tab-home" data-value="#home" data-toggle="tab">Home</a></li>
<li><a href="#tab-fav" data-value="#fav" data-toggle="tab">Favorites</a></li>
<li><a href="#tab-fr" data-value="#fr" data-toggle="tab">Friends</a></li>
<li><a href="#tab-ex" data-value="#ex" data-toggle="tab">Experience</a></li>
</ul>
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade in active" id="tab-home">
HOME
</div>
<div class="tab-pane fade active" id="tab-fav">
My favorites
</div>
<div class="tab-pane fade active" id="tab-fr">
My Friends
</div>
<div class="tab-pane fade active" id="tab-ex">
My experience
</div>
</div>
<script type="text/javascript">
$(function () {
var navTabs = $('.nav-tabs a');
var hash = window.location.hash;
hash && navTabs.filter('[data-value="' + hash + '"]').tab('show');
navTabs.on('shown', function (e) {
var newhash = $(e.target).attr('data-value');
window.location.hash = newhash;
});
})
</script>
</div>
Can anyone help me figure out what's wrong and how to fix it?