Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9255203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:39:46+00:00 2026-06-18T11:39:46+00:00

I have four different divs in my html that i want to keep hidden

  • 0

I have four different divs in my html that i want to keep hidden and then show the one of my choice depending on which link i click on. However, i cant hide them. It wont work, and i want whatever that is in respective div to be shown under the links, not next to them as they do now. My biggest difficaulty is to hide my divs, any solution?

Javascript

function show1(){
var minaP = document.getElementByID("one");
minaP.style.visibility = "visible";
}

function show2(){
var minaP = document.getElementById("two");
minaP.style.visibility = "visible";
}

function show3(){
var minaP = document.getElementById("three");
minaP.style.visibility = "visible";
}

function show4(){
var minaP = document.getElementById("four");
minaP.style.visibility = "visible";
}

function init() {

var minaDiv = document.getElementsByTagName("div");
for(i=0; i<minaDiv.length; i++){
  minaDiv[i].style.visibility = "hidden";
}

var minaA = document.getElementsByTagName("a");
for(i=0; i<minaA.length; i++){
  if(document.getElementById == "1"){
    minaA.onclick = show1;
  }
}

}

window.onload = init;

Html

<div>
<ul class="meny">
<li><a href="#" id="1">Utvärdering/Feedback</a></li>
<li><a href="#" id="2">Kontakt</a></li>
<li><a href="#" id="3">Öppettider</a></li>
<li><a href="#" id="4">Om Asperöd</a></li>
</ul>
</div>

<div id="one">
<p><b>Aperåd Äventyrsland</b></p> 
<p>Växel: 0200-123456999 (kl.08:30-15)</p>
<p>Stora Vägen 140</p>
<p>289 22 Aperöd</p>
<p>Skicka oss din <a href="#">fråga</a></p>
</div>
<div id="two">
<p>Du kan kontakta oss på följande nummer: 
<br> 040-123456
</p>
<p> Du kan även mejla oss:
<br> aperöd@hotmail.com
</p>
</div>
<div id="three">
<p>Vi har följande öppettider:</p>
<p> Mån-Fre: 10:00 - 20:00 </p>
<p> Lör: 10:00 - 18:00 </p>
</div>
<div id="four">

Aperöd är en fin park för alla möjliga personer. Vi erbjuder en massa, men det kostar 500kr

för att delta för en dag.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T11:39:47+00:00Added an answer on June 18, 2026 at 11:39 am

    Maybe you should consider using/learning jQuery. It helps reducing code size and there are a lot of fancy animations 😉

    Here a fast demo with .hide() .show()

    http://jsfiddle.net/yFhX5/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have four different tables, one main SPECIAL table containing only id's that reference
Hi I have a page for which I have four different style sheets like
I have a program with four different buttons. I want to interchange the position
I have this simple program that computes salaries for four different worker types. It's
I have a page that needs to combine data from four different webrequests into
I have a LINQ to SQL DataContext that queries four different tables. But I
Imagine i have this HTML snippet 4 times over for four different sections of
I have four screens that are exactly the same except they use four different
Ok I have four parameters in the url xxx.html?p1=something&p2=else&p3=here&p4=too And I have five different
I have four wheels which spin with the numbers 0-9: I want to be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.