I'm trying to target a UL that's inside a LI and I'm having trouble. Here's the HTML:
<ul id="main_nav">
<li class="main"><a href="#">Section 1</a>
<ul id="dropdown">
<li><a href="#">Item 1</a></li>
<li><a href="#">Item 2</a></li>
<li><a href="#">Item 2</a></li>
</ul>
</li>
<li class="main"><a href="#">Section 2</a>
<ul id="dropdown">
<li><a href="#">Item 1</a></li>
<li><a href="#">Item 2</a></li>
<li><a href="#">Item 2</a></li>
</ul>
</li>
<li class="main"><a href="#">Section 3</a></span>
<ul id="dropdown">
<li><a href="#">Item 1</a></li>
<li><a href="#">Item 2</a></li>
<li><a href="#">Item 2</a></li>
</ul>
</li>
and here's the JS:
window.addEvent('load', function() {
$$('li.main').each(function(el){
el.getChild('dropdown').addEvent('mouseenter',function(e){
alert("over!");
});
el.getChild('dropdown').addEvent('mouseleave',function(e){
alert("out!");
});
});
}
I think the problem is when I try to get the child of the LI by using el.getChild('dropdown'), but I don't know any other ways to do this. I'm not a coder so any help is appreciated. Thanks!