开发者

jQuery select "not this and not everything in this"

I got a plugin

$.fn.dropDown = function(options){
    this.each(function(){
        var $this= $(this);
        $(document).click(function(e){
      开发者_如何学JAVA      if($(e.target).not($this) && $(e.target).not($this).find('*')){
                // do stuff
            }
        }); 

    });
}

I want to select "not this and not everything in this" ,so far, that doesn't work.


This should work:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜