⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jquery-1.3.1.js

📁 ajaxpro
💻 JS
📖 第 1 页 / 共 5 页
字号:
	slice: function() {		return this.pushStack( Array.prototype.slice.apply( this, arguments ),			"slice", Array.prototype.slice.call(arguments).join(",") );	},	map: function( callback ) {		return this.pushStack( jQuery.map(this, function(elem, i){			return callback.call( elem, i, elem );		}));	},	andSelf: function() {		return this.add( this.prevObject );	},	domManip: function( args, table, callback ) {		if ( this[0] ) {			var fragment = (this[0].ownerDocument || this[0]).createDocumentFragment(),				scripts = jQuery.clean( args, (this[0].ownerDocument || this[0]), fragment ),				first = fragment.firstChild,				extra = this.length > 1 ? fragment.cloneNode(true) : fragment;			if ( first )				for ( var i = 0, l = this.length; i < l; i++ )					callback.call( root(this[i], first), i > 0 ? extra.cloneNode(true) : fragment );						if ( scripts )				jQuery.each( scripts, evalScript );		}		return this;				function root( elem, cur ) {			return table && jQuery.nodeName(elem, "table") && jQuery.nodeName(cur, "tr") ?				(elem.getElementsByTagName("tbody")[0] ||				elem.appendChild(elem.ownerDocument.createElement("tbody"))) :				elem;		}	}};// Give the init function the jQuery prototype for later instantiationjQuery.fn.init.prototype = jQuery.fn;function evalScript( i, elem ) {	if ( elem.src )		jQuery.ajax({			url: elem.src,			async: false,			dataType: "script"		});	else		jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );	if ( elem.parentNode )		elem.parentNode.removeChild( elem );}function now(){	return +new Date;}jQuery.extend = jQuery.fn.extend = function() {	// copy reference to target object	var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options;	// Handle a deep copy situation	if ( typeof target === "boolean" ) {		deep = target;		target = arguments[1] || {};		// skip the boolean and the target		i = 2;	}	// Handle case when target is a string or something (possible in deep copy)	if ( typeof target !== "object" && !jQuery.isFunction(target) )		target = {};	// extend jQuery itself if only one argument is passed	if ( length == i ) {		target = this;		--i;	}	for ( ; i < length; i++ )		// Only deal with non-null/undefined values		if ( (options = arguments[ i ]) != null )			// Extend the base object			for ( var name in options ) {				var src = target[ name ], copy = options[ name ];				// Prevent never-ending loop				if ( target === copy )					continue;				// Recurse if we're merging object values				if ( deep && copy && typeof copy === "object" && !copy.nodeType )					target[ name ] = jQuery.extend( deep, 						// Never move original objects, clone them						src || ( copy.length != null ? [ ] : { } )					, copy );				// Don't bring in undefined values				else if ( copy !== undefined )					target[ name ] = copy;			}	// Return the modified object	return target;};// exclude the following css properties to add pxvar	exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,	// cache defaultView	defaultView = document.defaultView || {},	toString = Object.prototype.toString;jQuery.extend({	noConflict: function( deep ) {		window.$ = _$;		if ( deep )			window.jQuery = _jQuery;		return jQuery;	},	// See test/unit/core.js for details concerning isFunction.	// Since version 1.3, DOM methods and functions like alert	// aren't supported. They return false on IE (#2968).	isFunction: function( obj ) {		return toString.call(obj) === "[object Function]";	},	isArray: function( obj ) {		return toString.call(obj) === "[object Array]";	},	// check if an element is in a (or is an) XML document	isXMLDoc: function( elem ) {		return elem.nodeType === 9 && elem.documentElement.nodeName !== "HTML" ||			!!elem.ownerDocument && jQuery.isXMLDoc( elem.ownerDocument );	},	// Evalulates a script in a global context	globalEval: function( data ) {		data = jQuery.trim( data );		if ( data ) {			// Inspired by code by Andrea Giammarchi			// http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html			var head = document.getElementsByTagName("head")[0] || document.documentElement,				script = document.createElement("script");			script.type = "text/javascript";			if ( jQuery.support.scriptEval )				script.appendChild( document.createTextNode( data ) );			else				script.text = data;			// Use insertBefore instead of appendChild  to circumvent an IE6 bug.			// This arises when a base node is used (#2709).			head.insertBefore( script, head.firstChild );			head.removeChild( script );		}	},	nodeName: function( elem, name ) {		return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase();	},	// args is for internal usage only	each: function( object, callback, args ) {		var name, i = 0, length = object.length;		if ( args ) {			if ( length === undefined ) {				for ( name in object )					if ( callback.apply( object[ name ], args ) === false )						break;			} else				for ( ; i < length; )					if ( callback.apply( object[ i++ ], args ) === false )						break;		// A special, fast, case for the most common use of each		} else {			if ( length === undefined ) {				for ( name in object )					if ( callback.call( object[ name ], name, object[ name ] ) === false )						break;			} else				for ( var value = object[0];					i < length && callback.call( value, i, value ) !== false; value = object[++i] ){}		}		return object;	},	prop: function( elem, value, type, i, name ) {		// Handle executable functions		if ( jQuery.isFunction( value ) )			value = value.call( elem, i );		// Handle passing in a number to a CSS property		return typeof value === "number" && type == "curCSS" && !exclude.test( name ) ?			value + "px" :			value;	},	className: {		// internal only, use addClass("class")		add: function( elem, classNames ) {			jQuery.each((classNames || "").split(/\s+/), function(i, className){				if ( elem.nodeType == 1 && !jQuery.className.has( elem.className, className ) )					elem.className += (elem.className ? " " : "") + className;			});		},		// internal only, use removeClass("class")		remove: function( elem, classNames ) {			if (elem.nodeType == 1)				elem.className = classNames !== undefined ?					jQuery.grep(elem.className.split(/\s+/), function(className){						return !jQuery.className.has( classNames, className );					}).join(" ") :					"";		},		// internal only, use hasClass("class")		has: function( elem, className ) {			return elem && jQuery.inArray( className, (elem.className || elem).toString().split(/\s+/) ) > -1;		}	},	// A method for quickly swapping in/out CSS properties to get correct calculations	swap: function( elem, options, callback ) {		var old = {};		// Remember the old values, and insert the new ones		for ( var name in options ) {			old[ name ] = elem.style[ name ];			elem.style[ name ] = options[ name ];		}		callback.call( elem );		// Revert the old values		for ( var name in options )			elem.style[ name ] = old[ name ];	},	css: function( elem, name, force ) {		if ( name == "width" || name == "height" ) {			var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ];			function getWH() {				val = name == "width" ? elem.offsetWidth : elem.offsetHeight;				var padding = 0, border = 0;				jQuery.each( which, function() {					padding += parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0;					border += parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0;				});				val -= Math.round(padding + border);			}			if ( jQuery(elem).is(":visible") )				getWH();			else				jQuery.swap( elem, props, getWH );			return Math.max(0, val);		}		return jQuery.curCSS( elem, name, force );	},	curCSS: function( elem, name, force ) {		var ret, style = elem.style;		// We need to handle opacity special in IE		if ( name == "opacity" && !jQuery.support.opacity ) {			ret = jQuery.attr( style, "opacity" );			return ret == "" ?				"1" :				ret;		}		// Make sure we're using the right name for getting the float value		if ( name.match( /float/i ) )			name = styleFloat;		if ( !force && style && style[ name ] )			ret = style[ name ];		else if ( defaultView.getComputedStyle ) {			// Only "float" is needed here			if ( name.match( /float/i ) )				name = "float";			name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase();			var computedStyle = defaultView.getComputedStyle( elem, null );			if ( computedStyle )				ret = computedStyle.getPropertyValue( name );			// We should always get a number back from opacity			if ( name == "opacity" && ret == "" )				ret = "1";		} else if ( elem.currentStyle ) {			var camelCase = name.replace(/\-(\w)/g, function(all, letter){				return letter.toUpperCase();			});			ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ];			// From the awesome hack by Dean Edwards			// http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291			// If we're not dealing with a regular pixel number			// but a number that has a weird ending, we need to convert it to pixels			if ( !/^\d+(px)?$/i.test( ret ) && /^\d/.test( ret ) ) {				// Remember the original values				var left = style.left, rsLeft = elem.runtimeStyle.left;				// Put in the new values to get a computed value out				elem.runtimeStyle.left = elem.currentStyle.left;				style.left = ret || 0;				ret = style.pixelLeft + "px";				// Revert the changed values				style.left = left;				elem.runtimeStyle.left = rsLeft;			}		}		return ret;	},	clean: function( elems, context, fragment ) {		context = context || document;		// !context.createElement fails in IE with an error but returns typeof 'object'		if ( typeof context.createElement === "undefined" )			context = context.ownerDocument || context[0] && context[0].ownerDocument || document;		// If a single string is passed in and it's a single tag		// just do a createElement and skip the rest		if ( !fragment && elems.length === 1 && typeof elems[0] === "string" ) {			var match = /^<(\w+)\s*\/?>$/.exec(elems[0]);			if ( match )				return [ context.createElement( match[1] ) ];		}		var ret = [], scripts = [], div = context.createElement("div");		jQuery.each(elems, function(i, elem){			if ( typeof elem === "number" )				elem += '';			if ( !elem )				return;			// Convert html string into DOM nodes			if ( typeof elem === "string" ) {				// Fix "XHTML"-style tags in all browsers				elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){					return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i) ?						all :						front + "></" + tag + ">";				});				// Trim whitespace, otherwise indexOf won't work as expected				var tags = jQuery.trim( elem ).toLowerCase();				var wrap =					// option or optgroup					!tags.indexOf("<opt") &&					[ 1, "<select multiple='multiple'>", "</select>" ] ||					!tags.indexOf("<leg") &&					[ 1, "<fieldset>", "</fieldset>" ] ||					tags.match(/^<(thead|tbody|tfoot|colg|cap)/) &&					[ 1, "<table>", "</table>" ] ||					!tags.indexOf("<tr") &&					[ 2, "<table><tbody>", "</tbody></table>" ] ||				 	// <thead> matched above					(!tags.indexOf("<td") || !tags.indexOf("<th")) &&					[ 3, "<table><tbody><tr>", "</tr></tbody></table>" ] ||					!tags.indexOf("<col") &&					[ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ] ||					// IE can't serialize <link> and <script> tags normally					!jQuery.support.htmlSerialize &&					[ 1, "div<div>", "</div>" ] ||					[ 0, "", "" ];				// Go to html and back, then peel off extra wrappers				div.innerHTML = wrap[1] + elem + wrap[2];				// Move to the right depth				while ( wrap[0]-- )					div = div.lastChild;				// Remove IE's autoinserted <tbody> from table fragments				if ( !jQuery.support.tbody ) {					// String was a <table>, *may* have spurious <tbody>					var tbody = !tags.indexOf("<table") && tags.indexOf("<tbody") < 0 ?						div.firstChild && div.firstChild.childNodes :						// String was a bare <thead> or <tfoot>						wrap[1] == "<table>" && tags.indexOf("<tbody") < 0 ?							div.childNodes :							[];					for ( var j = tbody.length - 1; j >= 0 ; --j )						if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length )							tbody[ j ].parentNode.removeChild( tbody[ j ] );					}				// IE completely kills leading whitespace when innerHTML is used				if ( !jQuery.support.leadingWhitespace && /^\s/.test( elem ) )					div.insertBefore( context.createTextNode( elem.match(/^\s*/)[0] ), div.firstChild );								elem = jQuery.makeArray( div.childNodes );			}			if ( elem.nodeType )				ret.push( elem );			else				ret = jQuery.merge( ret, elem );		});		if ( fragment ) {			for ( var i = 0; ret[i]; i++ ) {				if ( jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {					scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );				} else {					if ( ret[i].nodeType === 1 )						ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) );					fragment.appendChild( ret[i] );				}			}						return scripts;		}		return ret;	},	attr: function( elem, name, value ) {		// don't set attributes on text and comment nodes		if (!elem || elem.nodeType == 3 || elem.nodeType == 8)			return undefined;		var notxml = !jQuery.isXMLDoc( elem ),			// Whether we are setting (or getting)			set = value !== undefined;		// Try to normalize/fix the name		name = notxml && jQuery.props[ name ] || name;		// Only do all the following if this is a node (faster for style)		// IE elem.getAttribute passes even for style		if ( elem.tagName ) {			// These attributes require special treatment			var special = /href|src|style/.test( name );			// Safari mis-reports the default selected property of a hidden option			// Accessing the parent's selectedIndex property fixes it			if ( name == "selected" && elem.parentNode )				elem.parentNode.selectedIndex;			// If applicable, access the attribute via the DOM 0 way

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -