0

所以我有一个关闭焦点的下拉菜单。我的问题是,在 ie 中,当您单击下拉 div 的滚动条时,focusout 事件触发并且菜单关闭...我尝试在单击时创建一个标志,但在 click 事件之前触发了 focusout 事件,所以标志没有好……我该怎么办?

$("input#" + selname + "i").focusout(function(){
    $("ul#" + selname + "ul").slideUp(500);
});
4

1 回答 1

0

解决方案:

$(document).mouseup(function (e) {
    if (!$("div." + selname + "wrapper").is(e.target) // if the target of the click isn't the container...
        && ($("div." + selname + "wrapper").has(e.target).length === 0) // ... nor a descendant of the container
        && (e.target != $("ul#" + selname + "ul").get(0))) // nor the scrollbar
    {
        $("ul#" + selname + "ul").slideUp(500);
        $("input[name=" + selname + "]").val(propvalarray[simplifyString($("input#" + selname + "i").val())].toUpperCase());
        checkProp();
    }
});

归功于@kurkula

于 2016-10-07T15:41:45.890 回答