I am using jquery to create two sets of tabs on a page. The tabs display images when clicked. The first set of tabs renders fine but the second set of tabs does not render. Here is the html:
<div id="ecimgtabs">
<ul>
<li id="first"><a href="#ltec1">IMAGEI</a></li>
<li id="second"><a href="#ltec2">IMAGEII</a></li>
</ul>
<div id="ltec1">
<img src="path"></img>
</div>
<div id="ltec2">
<img src="path"></img>
</div>
</div>
<div id="ecimgtabs">
<ul>
<li id="first"><a href="#stec1">IMAGEI </a></li>
<li id="second"><a href="#stec2">IMAGEII </a></li>
</ul>
<div id="stec1">
<img src="path"></img>
</div>
<div id="stec2">
<img src="path"></img>
</div>
</div>
Here’s the jquery script:
$(document).ready(function(){
var tabdiv = $('#ecimgtabs div');
$('#ecimgtabs div').hide();
$('#ecimgtabs div:first').show();
$('#ecimgtabs ul li:first').addClass('selected');
$('#ecimgtabs ul li a').click(function(){
$('#ecimgtabs ul li').removeClass('selected');
$(this).parent().addClass('selected');
var currentTab = $(this).attr('href');
$('#ecimgtabs div').hide();
$(currentTab).show();
return false;
});
});
Ok, I was able to figure this out. I changed the div IDs to be separate. So the 1st div changed to lecimgtabs and the next one secimgtabs. I am sure you could do it with identical IDs but this worked for me.Here’s the updated code:
@kyle there was no issue with the css.