diff options
author | Yehuda Katz <wycats@gmail.com> | 2009-12-09 12:43:13 -0800 |
---|---|---|
committer | John Resig <jeresig@gmail.com> | 2009-12-09 12:43:13 -0800 |
commit | 4e27f17007c2329e31b449e61bb31197b90a37f1 (patch) | |
tree | 78feeb48b09ad8d78fd93e4a65be7bd22af2cd22 /src/traversing.js | |
parent | 9e60fec46b2394541f75da3e333094d41069e84f (diff) | |
download | jquery-4e27f17007c2329e31b449e61bb31197b90a37f1.tar.gz jquery-4e27f17007c2329e31b449e61bb31197b90a37f1.zip |
Landing in jQuery.contains, jQuery.fn.contains, and jQuery.fn.has support. Fixes #4101.
Diffstat (limited to 'src/traversing.js')
-rw-r--r-- | src/traversing.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/traversing.js b/src/traversing.js index 57621a390..d6947ace6 100644 --- a/src/traversing.js +++ b/src/traversing.js @@ -57,6 +57,21 @@ jQuery.fn.extend({ return ret; }, + has: function( target ) { + var targets = jQuery( target ); + return this.filter(function() { + for ( var i = 0, l = targets.length; i < l; i++ ) { + if ( jQuery.contains( this, targets[i] ) ) { + return true; + } + } + }); + }, + + contains: function( target ) { + return this.has( target ).length > 0; + }, + not: function( selector ) { return this.pushStack( winnow(this, selector, false), "not", selector); }, |