View Single Post
Old 01-16-2013, 01:32 AM   PM User | #1
carevealed
New to the CF scene

 
Join Date: Jan 2013
Posts: 1
Thanks: 1
Thanked 0 Times in 0 Posts
carevealed is an unknown quantity at this point
getElementsByClassName to call multiple classes of same name

I have several sections of content on my site that are default 'hidden' in CSS. I use the getElementById so visitors can open each section of content individually. I now would like to add the option to open ALL content at once. All sections are contained in <div> tags with the class="show". How could I do this with getElementsByClassName?

Here's what I have so far:

function showHideAll(className) {
document.getElementsByClassName(className).style.display = 'block';
}


<a href="#" id="showAll" class="showLink" onclick="showAll('show');return false;">SHOW ALL CONTENT</a>


<div id="content" class="show">CONTENT 1</div>
<div id="content2" class="show">CONTENT 2</div>
<div id="content3" class="show">CONTENT 3</div>

EXAMPLE PAGE:
http://carevealed.com/cc.php
carevealed is offline   Reply With Quote