I've got a simple jquery menu set up... it works fine except for the parent item. I've only listed one parent item, but there may be many, so raw #id won't work for this either. I want to apply a class when it is CLICKED, but then remove that class when the user hovers elsewhere and the menu slides away.
Here is what I have so far that isn't working for me.
<script type="text/javascript">
$(document).ready(function () {
$("ul.topnav li a").click(function () {
$(this).parent().find("ul.subnav").slideDown('fast').show();
$(this).parent().hover(function () {
}, function () {
$(this).parent().find("ul.subnav").slideUp('slow');
$(this).parent().removeClass("subhover");
});
}).before(function () {
$(this).addClass("subhover");
});
});
<ul class="topnav">
<li><a href="#">Item 1</a></li>
<li class="dropdownmenu">
<a href="#">Menu Parent</a>
<ul class="subnav">
<li>Item</li>
</ul>
</li>
</ul>