Html code is:
<div id="questions">
<ul>
<li class="selected"><a href="#fly">Fly</a></li>
<li><a href="#fly1">Fly 1</a></li>
</ul>
<div id="fly" style="display: block;">
<div id="question141">
<div id="question104">
<div id="question80">
<div id="question79">
</div>
<div id="fly1">
<div id="question141">
<div id="question104">
<div id="question80" >
<div id="question79" >
</div>
</div>
jQuery:
<script>
jQuery(document).ready(function(){
jQuery('#questions div').hide();
jQuery('#questions div:first').show();
jQuery('#questions ul li:first').addClass('active');
jQuery('#questions ul li a').click(function(){
jQuery('#questions ul li').removeClass('active');
jQuery(this).parent().addClass('active');
var currentTab = jQuery(this).attr('href');
jQuery('#questions div').hide();
jQuery(currentTab).show();
return false;
});
});
</script>
Above code has two tabs and i am using jQuery to show tabs on click. But when i click any tab. The elements inside the tab does not show. Am i doing something wrong?
When you say jQuery(‘#questions div’).hide() or show() it will hide all divs inside #questions div. Please try below code it will work for you.