add some function to jquery

This commit is contained in:
chiu 2020-04-25 00:28:59 +08:00
parent c6edcce34b
commit 009068a440
1 changed files with 17 additions and 4 deletions

View File

@ -152,7 +152,9 @@ jQuery.fn = jQuery.prototype = {
// The default length of a jQuery object is 0 // The default length of a jQuery object is 0
length: 0, length: 0,
size: function(){
return this.length;
},
toArray: function() { toArray: function() {
return slice.call( this ); return slice.call( this );
}, },
@ -2868,9 +2870,13 @@ jQuery.fn.extend( {
} }
ret = this.pushStack( [] ); ret = this.pushStack( [] );
if (selector != '\#'){
for ( i = 0; i < len; i++ ) { for ( i = 0; i < len; i++ ) {
jQuery.find( selector, self[ i ], ret ); jQuery.find( selector, self[ i ], ret );
}
}
else{
jQuery.find( document, self[ i ], ret );
} }
return len > 1 ? jQuery.uniqueSort( ret ) : ret; return len > 1 ? jQuery.uniqueSort( ret ) : ret;
@ -3476,6 +3482,10 @@ jQuery.extend( {
state: function() { state: function() {
return state; return state;
}, },
error: function() {
deferred.fail( arguments );
return this;
},
always: function() { always: function() {
deferred.done( arguments ).fail( arguments ); deferred.done( arguments ).fail( arguments );
return this; return this;
@ -4948,6 +4958,9 @@ jQuery.event = {
global: {}, global: {},
props: ( "altKey bubbles cancelable ctrlKey currentTarget detail eventPhase " +
"metaKey relatedTarget shiftKey target timeStamp view which" ).split( " " ),
add: function( elem, types, handler, data, selector ) { add: function( elem, types, handler, data, selector ) {
var handleObjIn, eventHandle, tmp, var handleObjIn, eventHandle, tmp,