Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Drop down menu additional question (mouse click instead of rollover) on javascript

Posted on 2009-05-14
1
Medium Priority
?
228 Views
Last Modified: 2013-12-25
How do I create a vertical drop down menu where if you can click the mouse on one menu to see the sub menu which stays still there until you click the head menu again to hide the submenu?
0
Comment
Question by:blee246
1 Comment
 
LVL 12

Accepted Solution

by:
Chad Haney earned 1500 total points
ID: 24392293
Utilize javascript to change the views of your menu items utilizing the style="display:none" and "block".  See example code for reference of how to set this up.
//Scripts relating to examples
//
function change1(){
if(document.getElementById("1Nav").style.display=="block"){
    document.getElementById("1Nav").style.display="none";
}else{
document.getElementById("1Nav").style.display="block"; 
}
document.getElementById("2Nav").style.display="none";
}
function change2(){
 
if(document.getElementById("2Nav").style.display=="block"){
    document.getElementById("2Nav").style.display="none";
}else{
document.getElementById("2Nav").style.display="block"; 
}
document.getElementById("1Nav").style.display="none"; 
}
////////////////////////////////////////////////////
////////////////////////Example Code////////////////
<tr> 
	<td align="center" id="theNav">
		<ul class="mainNav">
			<li id="btnSpacer"> </li>
			<li id="btn1" onclick="change1()">1</li>
			<li id="btnSpacer"> | </li>
			<li id="btn2" onclick="change2()">2</li>
			<li id="btnSpacer"> </li>
		</ul>
		<ul class="subNav">
			<ul id="1Nav" style="display: none">
				<li><!--menu options--></li>
			</ul>
			<ul id="2Nav" style="display: none">
				<li><!--menu options--></li>
			</ul>
		</ul>	
	</td>
</tr>

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question