Hello,
I am new to JS, and I’m trying to workout some skill.
I decided to create a page with a menu that displays when you hover over it.
The element that triggers the onmouseover is the LINK at the top of the menu and also the DIV containing the LINK.
The menu itself is a UL.
The problem is that as soon as the page loads, all the ULs are styled as block.
I managed to narrow the problem, and it is the displayObj function.
The CSS is not an issue here.
Please advise
<div id="menu">
<div>
<a href="menu1.html">Home</a>
<ul>
<li>News</li>
<li>Gallery</li>
<li>Blog</li>
</ul>
</div>
<div>
<a href="menu2.html">Research</a>
<ul>
<li>Soul Shoes</li>
<li>Helvetivca History</li>
<li>Chicken Flags</li>
</ul>
</div>
</div>
window.onload = initAll;
function initAll(){
menuDiv = document.getElementById("menu");
menuATags = menuDiv.getElementsByTagName("a");
var adjasentUl = new Array();
for ( var i=0; i < menuATags.length; i++){
if(menuATags[i].parentNode.tagName == "DIV"){
adjasentUl[i] = menuATags[i].nextSibling.nextSibling;
if(adjasentUl[i].tagName == "UL"){
menuATags[i].onclick = retFalse;
menuATags[i].onmouseover = displayObj(adjasentUl[i]);
menuATags[i].onmouseout = hideObj(adjasentUl[i])
menuATags[i].parentNode.onmouseover = displayObj(adjasentUl[i]);
menuATags[i].parentNode.onmouseout = hideObj(adjasentUl[i]);
adjasentUl[i].onmouseover = displayObj(adjasentUl[i]);
adjasentUl[i].onmouseout = hideObj(adjasentUl[i]);
}
}
}
function displayObj(toShow){
toShow.style.display = "block";
}
function hideObj(toHide){
toHide.style.display = "hidden";
}
function retFalse(){
return false;
}
}