When I click tab 2 it is displaying the content along with tab 1. I tried using prev() to hide the previous element. But it is hiding the whole tab menu and also active tab is not changing color. i have attached the jsfiddle link below https://jsfiddle.net/nn9bqpsn/1/
<div class="Tabs">
<ul>
<li id="tab1" class="Active">Tab 1</li>
<li id="tab2">Tab 2</li>
<li id="tab3">Tab 3</li>
</ul>
</div>
<div id="tab1-content" class="Tab" style="display:none">
<p>Tab 1 Content</p>
</div>
<div id="tab2-content" class="Tab" style="display:none">
<p>Tab 2 Content</p>
</div>
<div id="tab3-content" class="Tab" style="display:none">
<p>Tab 3 Content</p>
</div>
<script>
$(document).ready(function () {
if ($('li #tab1 .active')) {
$('#tab1-content').show();
}
});
$('#tab1').click(function () {
$('#tab1-content').prev().hide();
$('#tab1-content').show();
});
$('#tab2').click(function () {
$('#tab2-content').prev().hide();
$('#tab2-content').show();
});
$('#tab3').click(function () {
$('#tab3-content').prev().hide();
$('#tab3-content').show();
});
</script>
I have also tried with anchor tag with href but still not working. Attached below the jsfiddle for tabs using href https://jsfiddle.net/cL42g4sb/