首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jQuery选择"not this and not everything in this“

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

Stack Overflow用户
提问于 2011-02-19 04:31:36
回答 1查看 207关注 0票数 1

我有一个插件

代码语言:javascript
复制
$.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
            }
        }); 

    });
}

我想选择"not this and not everything in this“,到目前为止,这不起作用。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-02-19 04:41:06

这应该是可行的:

代码语言:javascript
复制
var that = this;
$(document).click(function(e) {
    if( e.target != that && !$.contains(that, e.target) ) {
        // do stuff
    }
});
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5046235

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档