diff options
author | John Resig <jeresig@gmail.com> | 2008-12-22 00:52:53 +0000 |
---|---|---|
committer | John Resig <jeresig@gmail.com> | 2008-12-22 00:52:53 +0000 |
commit | 6b090328643988869e2288a4874935680d8573ca (patch) | |
tree | 54ac9a37ae9ef7ea4ed41a65364e0372a3782d3d /src/core.js | |
parent | c9dd5d997229919b8dd4cc402b7b7a465982071a (diff) | |
download | jquery-6b090328643988869e2288a4874935680d8573ca.tar.gz jquery-6b090328643988869e2288a4874935680d8573ca.zip |
Added support for the new .closest() method (very useful for event delegation).
Diffstat (limited to 'src/core.js')
-rw-r--r-- | src/core.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/core.js b/src/core.js index 7ddb2c5b0..ff8114bb5 100644 --- a/src/core.js +++ b/src/core.js @@ -338,6 +338,17 @@ jQuery.fn = jQuery.prototype = { }) ), "filter", selector ); }, + closest: function( selector ) { + return this.map(function(){ + var cur = this; + while ( cur && cur.ownerDocument ) { + if ( jQuery(cur).is(selector) ) + return cur; + cur = cur.parentNode; + } + }); + }, + not: function( selector ) { if ( typeof selector === "string" ) // test special case where just one selector is passed in |