
Originally Posted by
iwdynamic
The function works on my page with one tab content. Can you modify it so i will work on a page with multiple tab contents?
Thank you!
Well, there are two directions you could go with that. Do you want one link that will reveal all tabs on a page regardless of what tab content group that they are a part of? Or, do you want separate links, each one revealing only all of the tabs in the group with which it is associated?
I think that for the first way it should work 'as is'. As long as all content divisions have the class 'tabcontent' (they are supposed to, according to the demo page).
For the second way, a unique identifier would have to be found for each group and the revealAll() function could test for that. For example, the id of each tabcontent division could be used as a secondary test if all tabcontent divisions in a given group shared an identical unique component. Say the divs were id'ed:
HTML Code:
<div id="first_tcontent1" class="tabcontent">
</div>
<div id="first_tcontent2" class="tabcontent">
</div>
and so on and the second group could be:
HTML Code:
<div id="sec_tcontent1" class="tabcontent">
</div>
<div id="sec_tcontent2" class="tabcontent">
</div>
Then the revealAll() function could look like so:
Code:
function revealAll(str){
var tabs=document.getElementsByTagName('div');
for (var i_tem = 0; i_tem < tabs.length; i_tem++)
if (tabs[i_tem].className=='tabcontent'&&tabs[i_tem].id.indexOf(str)>-1)
tabs[i_tem].style.display='block';
}
And could be called these two ways, for the two types of content divs I've already outlined:
HTML Code:
<li><a href="#" onclick="revealAll('first');return false;">Show All</a></li>
and:
HTML Code:
<li><a href="#" onclick="revealAll('sec');return false;">Show All</a></li>
Bookmarks