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

📄 jquery.js

📁 jQuery即学即用
💻 JS
📖 第 1 页 / 共 5 页
字号:
			.replace(/(?:^|:|,)(?:\s*\[)+/g, "")) ) {			// Try to use the native JSON parser first			return window.JSON && window.JSON.parse ?				window.JSON.parse( data ) :				(new Function("return " + data))();		} else {			jQuery.error( "Invalid JSON: " + data );		}	},	noop: function() {},	// Evalulates a script in a global context	globalEval: function( data ) {		if ( data && rnotwhite.test(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,			isObj = length === undefined || jQuery.isFunction(object);		if ( args ) {			if ( isObj ) {				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 ( isObj ) {				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;	},	trim: function( text ) {		return (text || "").replace( rtrim, "" );	},	// results is for internal usage only	makeArray: function( array, results ) {		var ret = results || [];		if ( array != null ) {			// The window, strings (and functions) also have 'length'			// The extra typeof function check is to prevent crashes			// in Safari 2 (See: #3039)			if ( array.length == null || typeof array === "string" || jQuery.isFunction(array) || (typeof array !== "function" && array.setInterval) ) {				push.call( ret, array );			} else {				jQuery.merge( ret, array );			}		}		return ret;	},	inArray: function( elem, array ) {		if ( array.indexOf ) {			return array.indexOf( elem );		}		for ( var i = 0, length = array.length; i < length; i++ ) {			if ( array[ i ] === elem ) {				return i;			}		}		return -1;	},	merge: function( first, second ) {		var i = first.length, j = 0;		if ( typeof second.length === "number" ) {			for ( var l = second.length; j < l; j++ ) {				first[ i++ ] = second[ j ];			}				} else {			while ( second[j] !== undefined ) {				first[ i++ ] = second[ j++ ];			}		}		first.length = i;		return first;	},	grep: function( elems, callback, inv ) {		var ret = [];		// Go through the array, only saving the items		// that pass the validator function		for ( var i = 0, length = elems.length; i < length; i++ ) {			if ( !inv !== !callback( elems[ i ], i ) ) {				ret.push( elems[ i ] );			}		}		return ret;	},	// arg is for internal usage only	map: function( elems, callback, arg ) {		var ret = [], value;		// Go through the array, translating each of the items to their		// new value (or values).		for ( var i = 0, length = elems.length; i < length; i++ ) {			value = callback( elems[ i ], i, arg );			if ( value != null ) {				ret[ ret.length ] = value;			}		}		return ret.concat.apply( [], ret );	},	// A global GUID counter for objects	guid: 1,	proxy: function( fn, proxy, thisObject ) {		if ( arguments.length === 2 ) {			if ( typeof proxy === "string" ) {				thisObject = fn;				fn = thisObject[ proxy ];				proxy = undefined;			} else if ( proxy && !jQuery.isFunction( proxy ) ) {				thisObject = proxy;				proxy = undefined;			}		}		if ( !proxy && fn ) {			proxy = function() {				return fn.apply( thisObject || this, arguments );			};		}		// Set the guid of unique handler to the same of original handler, so it can be removed		if ( fn ) {			proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;		}		// So proxy can be declared as an argument		return proxy;	},	// Use of jQuery.browser is frowned upon.	// More details: http://docs.jquery.com/Utilities/jQuery.browser	uaMatch: function( ua ) {		ua = ua.toLowerCase();		var match = /(webkit)[ \/]([\w.]+)/.exec( ua ) ||			/(opera)(?:.*version)?[ \/]([\w.]+)/.exec( ua ) ||			/(msie) ([\w.]+)/.exec( ua ) ||			!/compatible/.test( ua ) && /(mozilla)(?:.*? rv:([\w.]+))?/.exec( ua ) ||		  	[];		return { browser: match[1] || "", version: match[2] || "0" };	},	browser: {}});browserMatch = jQuery.uaMatch( userAgent );if ( browserMatch.browser ) {	jQuery.browser[ browserMatch.browser ] = true;	jQuery.browser.version = browserMatch.version;}// Deprecated, use jQuery.browser.webkit insteadif ( jQuery.browser.webkit ) {	jQuery.browser.safari = true;}if ( indexOf ) {	jQuery.inArray = function( elem, array ) {		return indexOf.call( array, elem );	};}// All jQuery objects should point back to theserootjQuery = jQuery(document);// Cleanup functions for the document ready methodif ( document.addEventListener ) {	DOMContentLoaded = function() {		document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );		jQuery.ready();	};} else if ( document.attachEvent ) {	DOMContentLoaded = function() {		// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).		if ( document.readyState === "complete" ) {			document.detachEvent( "onreadystatechange", DOMContentLoaded );			jQuery.ready();		}	};}// The DOM ready check for Internet Explorerfunction doScrollCheck() {	if ( jQuery.isReady ) {		return;	}	try {		// If IE is used, use the trick by Diego Perini		// http://javascript.nwbox.com/IEContentLoaded/		document.documentElement.doScroll("left");	} catch( error ) {		setTimeout( doScrollCheck, 1 );		return;	}	// and execute any waiting functions	jQuery.ready();}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 );	}}// Mutifunctional method to get and set values to a collection// The value/s can be optionally by executed if its a functionfunction access( elems, key, value, exec, fn, pass ) {	var length = elems.length;		// Setting many attributes	if ( typeof key === "object" ) {		for ( var k in key ) {			access( elems, k, key[k], exec, fn, value );		}		return elems;	}		// Setting one attribute	if ( value !== undefined ) {		// Optionally, function values get executed if exec is true		exec = !pass && exec && jQuery.isFunction(value);				for ( var i = 0; i < length; i++ ) {			fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );		}				return elems;	}		// Getting an attribute	return length ? fn( elems[0], key ) : undefined;}function now() {	return (new Date).getTime();}(function() {	jQuery.support = {};	var root = document.documentElement,		script = document.createElement("script"),		div = document.createElement("div"),		id = "script" + now();	div.style.display = "none";	div.innerHTML = "   <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";	var all = div.getElementsByTagName("*"),		a = div.getElementsByTagName("a")[0];	// Can't get basic test support	if ( !all || !all.length || !a ) {		return;	}	jQuery.support = {		// IE strips leading whitespace when .innerHTML is used		leadingWhitespace: div.firstChild.nodeType === 3,		// Make sure that tbody elements aren't automatically inserted		// IE will insert them into empty tables		tbody: !div.getElementsByTagName("tbody").length,		// Make sure that link elements get serialized correctly by innerHTML		// This requires a wrapper element in IE		htmlSerialize: !!div.getElementsByTagName("link").length,		// Get the style information from getAttribute		// (IE uses .cssText insted)		style: /red/.test( a.getAttribute("style") ),		// Make sure that URLs aren't manipulated		// (IE normalizes it by default)		hrefNormalized: a.getAttribute("href") === "/a",		// Make sure that element opacity exists		// (IE uses filter instead)		// Use a regex to work around a WebKit issue. See #5145		opacity: /^0.55$/.test( a.style.opacity ),		// Verify style float existence		// (IE uses styleFloat instead of cssFloat)		cssFloat: !!a.style.cssFloat,		// Make sure that if no value is specified for a checkbox		// that it defaults to "on".		// (WebKit defaults to "" instead)		checkOn: div.getElementsByTagName("input")[0].value === "on",		// Make sure that a selected-by-default option has a working selected property.		// (WebKit defaults to false instead of true, IE too, if it's in an optgroup)		optSelected: document.createElement("select").appendChild( document.createElement("option") ).selected,		parentNode: div.removeChild( div.appendChild( document.createElement("div") ) ).parentNode === null,		// Will be defined later		deleteExpando: true,		checkClone: false,		scriptEval: false,		noCloneEvent: true,		boxModel: null	};	script.type = "text/javascript";	try {		script.appendChild( document.createTextNode( "window." + id + "=1;" ) );	} catch(e) {}	root.insertBefore( script, root.firstChild );	// Make sure that the execution of code works by injecting a script	// tag with appendChild/createTextNode	// (IE doesn't support this, fails, and uses .text instead)	if ( window[ id ] ) {		jQuery.support.scriptEval = true;		delete window[ id ];	}	// Test to see if it's possible to delete an expando from an element	// Fails in Internet Explorer	try {		delete script.test;		} catch(e) {		jQuery.support.deleteExpando = false;	}	root.removeChild( script );	if ( div.attachEvent && div.fireEvent ) {		div.attachEvent("onclick", function click() {			// Cloning a node shouldn't copy over any			// bound event handlers (IE does this)			jQuery.support.noCloneEvent = false;			div.detachEvent("onclick", click);		});		div.cloneNode(true).fireEvent("onclick");	}	div = document.createElement("div");	div.innerHTML = "<input type='radio' name='radiotest' checked='checked'/>";	var fragment = document.createDocumentFragment();	fragment.appendChild( div.firstChild );	// WebKit doesn't clone checked state correctly in fragments	jQuery.support.checkClone = fragment.cloneNode(true).cloneNode(true).lastChild.checked;	// Figure out if the W3C box model works as expected	// document.body must exist before we can do this	jQuery(function() {		var div = document.createElement("div");		div.style.width = div.style.paddingLeft = "1px";		document.body.appendChild( div );		jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;		document.body.removeChild( div ).style.display = 'none';		div = null;	});	// Technique from Juriy Zaytsev	// http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/	var eventSupported = function( eventName ) { 		var el = document.createElement("div"); 		eventName = "on" + eventName; 		var isSupported = (eventName in el); 		if ( !isSupported ) { 			el.setAttribute(eventName, "return;"); 			isSupported = typeof el[eventName] === "function"; 		} 		el = null; 		return isSupported; 	};		jQuery.support.submitBubbles = eventSupported("submit");	jQuery.support.changeBubbles = eventSupported("change");	// release memory in IE	root = script = div = all = a = null;})();jQuery.props = {	"for": "htmlFor",	"class": "className",	readonly: "readOnly",	maxlength: "maxLength",	cellspacing: "cellSpacing",	rowspan: "rowSpan",	colspan: "colSpan",	tabindex: "tabIndex",	usemap: "useMap",	frameborder: "frameBorder"};var expando = "jQuery" + now(), uuid = 0, windowData = {};jQuery.extend({	cache: {},		expando:expando,	// The following elements throw uncatchable exceptions if you	// attempt to add expando properties to them.	noData: {		"embed": true,		"object": true,		"applet": true	},	data: function( elem, name, data ) {		if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {			return;		}		elem = elem == window ?			windowData :			elem;		var id = elem[ expando ], cache = jQuery.cache, thisCache;		if ( !id && typeof name === "string" && data === undefined ) {			return null;		}

⌨️ 快捷键说明

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