HTML:
<script>function dropdown()
{ console.getElementById("").style.display="block";
}</script>
<div id="dropdown">
<ul>
<li onclick="dropdown()"><a>Menu</a>
<ul id="Menuitems">
<li><a href="">item 1</a> </li>
<li><a href="">item 2</a> </li>
<li><a href="">item 3</a> </li>
</ul>
</li>
</ul>
</div>
Css:
#dropdown ul{
display: block;
}
#dropdown ul li {
display: block;
background-color: #558c89;
color: #ffffff;
}
#dropdown ul li ul {
display: none;
}
#dropdown ul li:hover > ul { /*this is what the onclick event should do*/
display: block;
}
The onclick should start the function "dropdown()" which needs to: "display: block;" on #dropdown ul li
You're missing the list ID and you're calling the selector on the console (when you want to be selecting on the document).
JSFiddle: http://jsfiddle.net/tmaB9/
Try:
This is important, so your function knows which element you clicked on. Then...
This will toggle the visibility of the submenu :)
here is a quick example of what i think you want (provided you can use JQuery):