gpt4 book ai didi

jQuery 选择 "not this and not everything in this"

转载 作者:行者123 更新时间:2023-12-01 07:32:26 25 4
gpt4 key购买 nike

我有一个插件

$.fn.dropDown = function(options){
this.each(function(){
var $this= $(this);
$(document).click(function(e){
if($(e.target).not($this) && $(e.target).not($this).find('*')){
// do stuff
}
});

});
}

我想选择“不是这个,也不是这个中的所有内容”,到目前为止,这不起作用。

最佳答案

这应该有效:

var that = this;
$(document).click(function(e) {
if( e.target != that && !$.contains(that, e.target) ) {
// do stuff
}
});

关于jQuery 选择 "not this and not everything in this",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5046235/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com