3

When I click the button, the green and yellow div closes but the c4 and c5 should also open up. Right now I have hidden it.

I don't know how to achieve it.

Providing my code below:

<div id="c4">content
    <button type="button">Click Me!</button>
</div>
<div id="c5">content
    <button type="button">Click Me!</button>
</div>

http://jsfiddle.net/c5WuM/11/

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • Are you able to use jquery? that would make this a lot easier http://stackoverflow.com/questions/596608/slide-right-to-left you could use the slide left method, and then the show and hide methods using jquery - a lot less code than what you have – birthofearth Mar 12 '14 at 02:34

1 Answers1

0

Why should they show? When you click on the c1 , you're hiding the other 2 but there is no code to make c4 and c5 appear. Am I missing something? Where is the code that should make c4 and c5 appear?

This line of code is only getting the elements for C1,C2 and C3. I don't know if you expect C4 and C5 to be in that array as well.

this.ch  = box.getElementsByTagName('DIV');

UPDATED:

I don't know where you want to fit this into your logic but here is how you would show/hide C4 and C5 with just javascript.

Show the elements -

document.getElementById("C4").style.display = "block";
document.getElementById("C5").style.display = "block"; 

Hide the elements -

document.getElementById("C4").style.display = "none"; 
document.getElementById("C5").style.display = "none";
VtoCorleone
  • 16,813
  • 5
  • 37
  • 51