我有两个容器 - 一个嵌套在另一个内部。当我悬停在父容器上时,我希望子容器出现。当我移开鼠标时,我希望子容器渐隐。问题是子容器中有一个包含“选择框”的表单。当用户选择选择框时,会意外触发mouseleave事件。
如何阻止选择框触发mouseleave事件?
您可以在此处查看我的工作代码:http://jsfiddle.net/rsturim/9TZyh/3/
以下是我的脚本摘要:
$('#parent-container').live("mouseenter", function () {
var $this = $(this),
$selectOptionsContainer = $this.find('#child-container');
$selectOptionsContainer.stop().fadeTo('slow', 1.0);
}).live("mouseleave", function (e) {
var $this = $(this),
$selectOptionsContainer = $this.find('#child-container');
$selectOptionsContainer.stop().hide();
});
编辑:在基于 WebKit 的浏览器中显示正常。在 Firefox 和 IE7-IE9 中出现错误。