mirror of
https://github.com/jquery/jquery.git
synced 2026-02-07 15:35:03 -05:00
Added support for the new .closest() method (very useful for event delegation).
This commit is contained in:
11
src/core.js
11
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
|
||||
|
||||
Reference in New Issue
Block a user