对于你们来说,下面的问题可能很容易,但我仍然试图了解jQuery。
假设我有一个按钮。当我将鼠标悬停时,div会在按钮底部向下滑动并代表一个下拉菜单。当我没有徘徊按钮时,菜单应该仍然存在,但显然不是因为当我将鼠标悬停在按钮上时我将其设置为打开。当我将鼠标悬停在另一个按钮上时,如何将菜单保留在那里并将其关闭?
感谢。
答案 0 :(得分:2)
http://jsfiddle.net/bSDwb/ - 这就是你想要的吗?
答案 1 :(得分:1)
也许这就是你所需要的(类似于tandu的回答,但我正在研究它,所以我还是要发布它) http://jsfiddle.net/hashie5/6qzu8/23/
答案 2 :(得分:0)
Hi as you are using hover event to show your pull down menu, you can keep your menu visible even you move your cursor from the button and to hide the menu you can use the following code, which runs on your mouse click anywhere else in the document.
// for taks sum menus ( to remove if user clicks anywhere else)
$(document).mouseup(function (e)
{
var container = $(".submenu"); //menu div class
if (!container.is(e.target) // if the target of the click isn't the container...
&& container.has(e.target).length === 0) // ... nor a descendant of the container
{
container.hide();
}
});
I hope this will help you.