I’ve got the script below
<script type="text/javascript">
$(document).ready(function () {
var ChildMenusFound = $(".menu_Child").hover(function () {
//Mouse Over
alert('ok');
$(this).toggleClass("menu_hover");
}, function () {
//Mouse Out
alert('ok');
$(this).toggleClass("menu_hover");
});
});
</Script>
The html I’m outputting is as follows:
<ul alt="" class="menu_Root">
<li class="menu_Child>"
<a href="/Admin" alt="">Admin</a>
<ul alt="" class="menu_Child">
<li class="menu_SubMenu>"
<a href="/Admin/Statistics" alt="">Statistics</a></li>
<li class="menu_SubMenu>"
<a href="/Admin/Database" alt="">Database</a></li>
</ul></li>
<li class="menu_Child>"
<a href="/MyAccount" alt="">My Account</a>
<ul alt="" class="menu_Child">
<li class="menu_SubMenu>"
<a href="/MyAccount/Profile" alt="">Profile</a></li>
</ul></li>
</ul>
after the call to hover(),ChildMenusFound contains 2 elements, firefox shows no JS errors, yet mouseover/out of the li elements doesn’t cause anything to happen.
Can someone please identify my mistake?
Your markup is broken. You’ve got quote marks outside the tags. It also looks like you’re missing a
</li>somewhere for that first outer</li>but it’s hard to tell.