Closed. This question is off-topic。它当前不接受答案。
                            
                        
                    
                
            
                    
                
                        
                            
                        
                    
                        
                            想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
                        
                        2年前关闭。
                    
                
        

当我单击表单的外部区域时,该表单将消失。
我在Chrome上实现了此功能。

$(window).on("click", function(e) {
    if( !$(event.target).closest('#login_form').length && !$(event.target).closest('#popup_btn').length ) {
        $("#login_form").fadeOut("slow");
        $("#popup_btn").fadeIn("slow");
        $(".nk-header-table").attr("id", "");
    }
});


但在Mozilla上不起作用。
我认为是因为最近的()方法。
我该如何处理?

最佳答案

尝试使用e.target代替event.target

09-25 18:43
查看更多