I know this topic has been asked before but looking through the posts isn't quite what I'm looking for so please bear with me for a minute.
first here's my little jQuery (works flawlessly)
$(document).ready(function(){
$(".tabs li").click(function() {
$(".tab-content").hide();
var selected_tab = $(this).find("a").attr("href");
$(selected_tab).fadeIn();
$(".tabs li").removeClass('current');
$(this).addClass("current");
return false;
});
});
And my basic HTML
<ul class="tabs">
<li class="active"><a href="#tab4">Tab 4</a></li>
<li><a href="#tab5"><div class="alert-icon">Tab 5</div></a></li>
<li><a href="#tab6"><div class="printer-icon">Tab 6</div></a></li>
</ul>
<div id="tab4" class="tab-content">Tab 4</div>
<div id="tab5" class="tab-content">Tab 5 </div>
<div id="tab6" class="tab-content">Tab 6 </div>
Naturally if I put more than 1 tab section on the page, every time a tab is clicked the content of all tabs will "hide" and I need to make each tabbed section behave independently.
My problem is I want to avoid going the ID route, ideally I can put the JS right into the template and every time someone needs a tabbed area they can just paste the HTML, maybe add an ID to the UL and fill in the blanks.
Tabs and their content will be put in by other not very tetchy people so if I can avoid having them use JS, life would be wonderful!
I thought about playing with filters, string replaces, child elements (put the divs in the LIs?) etc. but before diving into an unfamiliar ocean without my ducky float I thought one of the pros here can give me a hint and point me in the right direction. js/jQuery was never my favorite ^^.
Thanks a lot!