0

我正在使用 jQuery 变量“mouseover”和“mouseout”在悬停在另一个元素上时显示一个 DIV 元素。

http://74.54.17.66/~adbuynet/case-studies/ - 如果您将鼠标悬停在右上角的“号召性用语”上,您会看到一个下拉菜单。

问题是,当将鼠标悬停在下拉菜单本身时,下拉菜单开始表现得很时髦并且不会保持打开状态。我的 jQuery 代码是:

    $("#call-to-action").mouseover(function(e) {     
    $("#call-to-action-dropdown").show("slide", { direction: "up" }, 200);  
    e.stopPropagation();
  });
  $("#call-to-action").mouseout(function(e) {     
    $("#call-to-action-dropdown").hide("slide", { direction: "up" }, 200);  
  });
}); 

请问我犯了什么错误?

4

1 回答 1

2

使用mouseenterandmouseleave代替mouseoverand mouseout。请参阅http://api.jquery.com/mouseenter/

(你几乎不会想使用mouseover/ mouseout,当你这样做时,你就会知道。)

于 2011-09-27T13:03:12.613 回答