enquest schrieb:
> I am puzzled how to build a good menu system.
>
> I need to put on 3 separated places a drop down hover menu. However if
> you build one then the second one makes the first one bad. I got an
> example on http://www.enquest.eu/test.html . What am I doing wrong.
>
The following code should do what you need, it's tested:
$(function() {
var toggle = function(direction, display) {
return function() {
var self = this;
var ul = $("ul", this);
if( ul.css("display") == display && !self["block" +
direction] ) {
self["block" + direction] = true;
ul["slide" + direction]("slow", function() {
self["block" + direction] = false;
});
}
};
}
$("li.menu").hover(toggle("Down", "none"), toggle("Up", "block"));
$("li.menu ul").hide();
});
I use a factory function to create the two functions for hover, as they
are almost the same. You have to love javascript to make such code
possible :-)
Notice the hide() at the end. I prefer to hide the menu via javascript
instead of css, therefore removed the "display: none" from the styles.
Hope that helps, thanks for the challenge :-)
--
Jörn Zaefferer
http://bassistance.de
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/