Jump to content

[SOLVED] div menu?


toshka89

Recommended Posts

Hi there all!!

 

I have a menu script so far that looks like this:

 

java script:

 

<script LANGUAGE="JavaScript">
<!--
function showHide(elementid){
if (document.getElementById(elementid).style.display == 'none'){
document.getElementById(elementid).style.display = '';
} else {
document.getElementById(elementid).style.display = 'none';
}
}
//-->
</SCRIPT>

 

HTML:

 

<a href="#welcome" onClick="java script:showHide('welcome')">
<div class="button" id="welcomeb"><strong>welcome</strong></div></a>
<div id="welcome" class="box">Welcome to Blah...!</div>

<a href="#about" onClick="java script:showHide('about')">
<div class="button" id="aboutb"><strong>about</strong></div></a>
<div id="about" class="box" style="display:none;">LALALA</div>

 

I was wondering how I could modify it, so that when I click on one menu link, the other menu DIVs will close?

 

A quick response will be HUGELY appreciated!

 

Peace,

Ant..

Link to comment
Share on other sites

It's because you're calling the wrong element ID's.

You have to call the ID of the Div.

 

<a href="#welcome" onClick="java script:showHide('welcomeb')">
<div class="button" id="welcomeb"><strong>welcome</strong></div></a>
<div id="welcome" class="box">Welcome to Blah...!</div>

<a href="#about" onClick="java script:showHide('aboutb')">
<div class="button" id="aboutb"><strong>about</strong></div></a>
<div id="about" class="box" style="display:none;">LALALA</div>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.