1 reply [Last post]
christopherson1403
christopherson1403's picture
Offline
newbie
Last seen: 7 years 23 weeks ago
Timezone: GMT-8
Joined: 2012-12-16
Posts: 1
Points: 2

<body>
<center>
<div id="header"></div>
<div id="wrapper">
<div id="content">
<div id="contenth">
<h1 id=>content header</h1>
</div>
content
<a href="#" onclick="changeDiv(1)">Menu 1</a> ///change to other div
<a href="#" onclick="changeDiv(2)">Menu 2</a>
<script>
function changeDiv(i){
if(i==1)
document.getElementById("content").innerHTML = document.getElementById("step2").innerHTML;
else
document.getElementById("step2").innerHTML = document.getElementById("content").innerHTML;
}
</script>
</div>
</div>
<div id="step2"> // Showed on click
<div id="step2h">//want to show this as well
<h1>STEP 2 Header</h1>
</div>
<h2>Step 2 Content</h2>
 
</div>
</center>
</body>

This is my current script and the step2 and step2h divs are hidden in css but I want to show not only step but step2h as well in one click.

//mod edit: Moved to "Off Topic" as this is a scripting question. ~gt

Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 4 days 11 hours ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5342
Points: 2963

You seem to be doing things

You seem to be doing things the hard way.
You should have shown how you are hiding the elements.

The function should be able to show any divs you want.
I'm not sure why you are playing around with innerHTML.

If you are hiding the divs with display:none; then just set them to display:block; when you want them to show.

 document.getElementById("step2").style.display="block";
 document.getElementById("step2h").style.display="block";