How to hide the submenus

P

Poornima

Hello

I have a html page with 2 layers,one for the main menu and the other
for the submenu.The submenu should be displayed on hovering on the main
menu is displayed else it should be hidden.

How can i get the above requirement using javascripts

can u plz give me the javascript code

Thanks In Advance

Poornima
 
M

Martijn Saly

Poornima said:
Hello

I have a html page with 2 layers,one for the main menu and the other
for the submenu.The submenu should be displayed on hovering on the main
menu is displayed else it should be hidden.

How can i get the above requirement using javascripts

can u plz give me the javascript code

Thanks In Advance

Poornima

showing and hiding can be done by setting obj.style.display to either
"", or "none".
 
A

ASM

Poornima a écrit :
Hello

I have a html page with 2 layers,one for the main menu and the other
for the submenu.The submenu should be displayed on hovering on the main
menu is displayed else it should be hidden.

How can i get the above requirement using javascripts

why not with css ?

a span { display: none }
a:hover span { display: block }


<a href=" ...>menu 1
<span>
<a href=" ...>submenu 1.1</a>
<a href=" ...>submenu 1.2</a>
</span>
can u plz give me the javascript code

HTML :
=======
<p><a onclick="show('d_1')" href=" ...>menu 1</a></p>

<div id="d_1" onclick="show(this.id)">
<p><a href=" ...>submenu 1.1</a>
<p><a href=" ...>submenu 1.2</a>
</div>

JavaScript :
============
function show(divId) (
divId = document.getElementById(divId).style;
divId.display = divId.display==''? 'none' : '';
}

onload = function() { show('d_1'); }

(not tested)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top