I'd make the following changes:
- Remove all usages of the "downclear" class. It's never referred to anywhere.
- Update the class "downservices2" to be "downservices", as thee is no difference in the CSS.
- Remove the JS code relating to downservices2.
- Modify the JS to attach to the class "downservices"
- Keep track of the last menu shown in a variable, and use this to know which menu to hide.
- Remove all usages of the "servicesdropped" and "servicesdropped2" classes.
Note: The CSS will need some way to refer to these for styling purposes. If the CSS for them will be identical, then use one class name shared between the ULs. The JS doesn't really need to refer to the class, as it'll only ever have 1 child UL.
This JS, along with the other CSS and HTML changes I mention should do the job:
Code:
<script type="text/javascript">
var lastMenu = null;
$(document).ready(function() {
$('.downservices').mouseleave(function() {
$(this).children('ul').slideUp('fast');
lastMenu = null;
});
$('.downservices').mouseenter(function() {
if (lastMenu) {
$(lastMenu).children('ul').slideUp('fast');
lastMenu = null;
}
lastMenu = $(this);
lastMenu.children('ul').slideDown('fast').show();
});
});
</script>
Note: This solution is also extensible to
n menus without having to code specifically for each one.
Hope this helps,
Dan
Coedit Limited - Delivering standards compliant, accessible web solutions
Dan's Page [blue]@[/blue] Code Couch:
Code Couch Snippets & Info: