In this program the sub menu item are does not hide when the mouse move to other items,I want to hide the sub menu items when mouse move from their area .can you help me?.I really want a drop-down menu on click.
#main li{
list-style-type: none;
display: none;
text-decoration: none;
}
#main{
cursor: pointer;
}
#pappaya {
background-color:#339933;
text-decoration: none;
}
#pappayas {
background-color:#339933;
text-decoration: none;
}
.orang{
text-decoration: none;
}
#pappaya li{
text-decoration: none;
}
<html>
<head>
<link rel="stylesheet" type="text/css" href="mango.css">
<script>
function mangoGrape(selector){
document.querySelectorAll(selector)
.forEach(function(node){
node.style.display="block";
})
}
</script>
</head>
<body>
</body>
<ul id="main" onclick="mangoGrape('.apple')">main1
<div id="pappaya">
<li class="apple"> <a href="#">sub1</a></li>
<li class="apple"><a href="#">sub2</a></li>
<li class="apple"><a href="#">sub3</a></li>
</div>
</ul>
<ul id="main" onclick="mangoGrape('.orang')">main2
<div id="pappayas">
<a href="#"><li class="orang">sub21</li></a>
<a href="#"><li class="orang">sub22</li></a>
<a href="#"><li class="orang">sub23</li></a>
</div>
</ul>
</html>
In this program the sub menu item are does not hide when the mouse move to other items,I want to hide the sub menu items when mouse move from their area .one another problem associated with this code is the text decoration property is not working properly.