aboutsummaryrefslogtreecommitdiffstats
path: root/src/core.js
diff options
context:
space:
mode:
authorJohn Resig <jeresig@gmail.com>2008-12-22 00:52:53 +0000
committerJohn Resig <jeresig@gmail.com>2008-12-22 00:52:53 +0000
commit6b090328643988869e2288a4874935680d8573ca (patch)
tree54ac9a37ae9ef7ea4ed41a65364e0372a3782d3d /src/core.js
parentc9dd5d997229919b8dd4cc402b7b7a465982071a (diff)
downloadjquery-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.js11
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