By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,043 Members | 1,275 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,043 IT Pros & Developers. It's quick & easy.

How to hide the submenus

P: n/a
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

Nov 21 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Poornima wrote:
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".

--
Martijn Saly
Nov 21 '06 #2

P: n/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>
</a>
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)
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Nov 21 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.