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

📄 jquery.js

📁 模拟的土豆网视频网站
💻 JS
📖 第 1 页 / 共 5 页
字号:
				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 ) {		var ret = [];		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;		jQuery.each(elems, function(i, elem){			if ( !elem )				return;			if ( elem.constructor == Number )				elem += '';			// 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(), div = context.createElement("div");				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.browser.msie &&					[ 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.browser.msie ) {					// 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 ( /^\s/.test( elem ) )						div.insertBefore( context.createTextNode( elem.match(/^\s*/)[0] ), div.firstChild );				}				elem = jQuery.makeArray( div.childNodes );			}			if ( elem.length === 0 && (!jQuery.nodeName( elem, "form" ) && !jQuery.nodeName( elem, "select" )) )				return;			if ( elem[0] == undefined || jQuery.nodeName( elem, "form" ) || elem.options )				ret.push( elem );			else				ret = jQuery.merge( ret, elem );		});		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,			msie = jQuery.browser.msie;		// 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" && jQuery.browser.safari )				elem.parentNode.selectedIndex;			// If applicable, access the attribute via the DOM 0 way			if ( name in elem && notxml && !special ) {				if ( set ){					// We can't allow the type property to be changed (since it causes problems in IE)					if ( name == "type" && jQuery.nodeName( elem, "input" ) && elem.parentNode )						throw "type property can't be changed";					elem[ name ] = value;				}				// browsers index elements by id/name on forms, give priority to attributes.				if( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) )					return elem.getAttributeNode( name ).nodeValue;				return elem[ name ];			}			if ( msie && notxml &&  name == "style" )				return jQuery.attr( elem.style, "cssText", value );			if ( set )				// convert the value to a string (all browsers do this but IE) see #1070				elem.setAttribute( name, "" + value );			var attr = msie && notxml && special					// Some attributes require a special call on IE					? elem.getAttribute( name, 2 )					: elem.getAttribute( name );			// Non-existent attributes return null, we normalize to undefined			return attr === null ? undefined : attr;		}		// elem is actually elem.style ... set the style		// IE uses filters for opacity		if ( msie && name == "opacity" ) {			if ( set ) {				// IE has trouble with opacity if it does not have layout				// Force it by setting the zoom level				elem.zoom = 1;				// Set the alpha filter to set the opacity				elem.filter = (elem.filter || "").replace( /alpha\([^)]*\)/, "" ) +					(parseInt( value ) + '' == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")");			}			return elem.filter && elem.filter.indexOf("opacity=") >= 0 ?				(parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100) + '':				"";		}		name = name.replace(/-([a-z])/ig, function(all, letter){			return letter.toUpperCase();		});		if ( set )			elem[ name ] = value;		return elem[ name ];	},	trim: function( text ) {		return (text || "").replace( /^\s+|\s+$/g, "" );	},	makeArray: function( array ) {		var ret = [];		if( array != null ){			var i = array.length;			//the window, strings and functions also have 'length'			if( i == null || array.split || array.setInterval || array.call )				ret[0] = array;			else				while( i )					ret[--i] = array[i];		}		return ret;	},	inArray: function( elem, array ) {		for ( var i = 0, length = array.length; i < length; i++ )		// Use === because on IE, window == document			if ( array[ i ] === elem )				return i;		return -1;	},	merge: function( first, second ) {		// We have to loop this way because IE & Opera overwrite the length		// expando of getElementsByTagName		var i = 0, elem, pos = first.length;		// Also, we need to make sure that the correct elements are being returned		// (IE returns comment nodes in a '*' query)		if ( jQuery.browser.msie ) {			while ( elem = second[ i++ ] )				if ( elem.nodeType != 8 )					first[ pos++ ] = elem;		} else			while ( elem = second[ i++ ] )				first[ pos++ ] = elem;		return first;	},	unique: function( array ) {		var ret = [], done = {};		try {			for ( var i = 0, length = array.length; i < length; i++ ) {				var id = jQuery.data( array[ i ] );				if ( !done[ id ] ) {					done[ id ] = true;					ret.push( array[ i ] );				}			}		} catch( e ) {			ret = array;		}		return ret;	},	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;	},	map: function( elems, callback ) {		var ret = [];		// 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++ ) {			var value = callback( elems[ i ], i );			if ( value != null )				ret[ ret.length ] = value;		}		return ret.concat.apply( [], ret );	}});var userAgent = navigator.userAgent.toLowerCase();// Figure out what browser is being usedjQuery.browser = {	version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1],	safari: /webkit/.test( userAgent ),	opera: /opera/.test( userAgent ),	msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),	mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent )};var styleFloat = jQuery.browser.msie ?	"styleFloat" :	"cssFloat";jQuery.extend({	// Check to see if the W3C box model is being used	boxModel: !jQuery.browser.msie || document.compatMode == "CSS1Compat",	props: {		"for": "htmlFor",		"class": "className",		"float": styleFloat,		cssFloat: styleFloat,		styleFloat: styleFloat,		readonly: "readOnly",		maxlength: "maxLength",		cellspacing: "cellSpacing"	}});jQuery.each({	parent: function(elem){return elem.parentNode;},	parents: function(elem){return jQuery.dir(elem,"parentNode");},	next: function(elem){return jQuery.nth(elem,2,"nextSibling");},	prev: function(elem){return jQuery.nth(elem,2,"previousSibling");},	nextAll: function(elem){return jQuery.dir(elem,"nextSibling");},	prevAll: function(elem){return jQuery.dir(elem,"previousSibling");},	siblings: function(elem){return jQuery.sibling(elem.parentNode.firstChild,elem);},	children: function(elem){return jQuery.sibling(elem.firstChild);},	contents: function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes);}}, function(name, fn){	jQuery.fn[ name ] = function( selector ) {		var ret = jQuery.map( this, fn );		if ( selector && typeof selector == "string" )			ret = jQuery.multiFilter( selector, ret );		return this.pushStack( jQuery.unique( ret ) );	};});jQuery.each({	appendTo: "append",	prependTo: "prepend",	insertBefore: "before",	insertAfter: "after",	replaceAll: "replaceWith"}, function(name, original){	jQuery.fn[ name ] = function() {		var args = arguments;		return this.each(function(){			for ( var i = 0, length = args.length; i < length; i++ )				jQuery( args[ i ] )[ original ]( this );		});	};});jQuery.each({	removeAttr: function( name ) {		jQuery.attr( this, name, "" );		if (this.nodeType == 1)			this.removeAttribute( name );	},	addClass: function( classNames ) {		jQuery.className.add( this, classNames );	},	removeClass: function( classNames ) {		jQuery.className.remove( this, classNames );	},	toggleClass: function( classNames ) {		jQuery.className[ jQuery.className.has( this, classNames ) ? "remove" : "add" ]( this, classNames );	},	remove: function( selector ) {		if ( !selector || jQuery.filter( selector, [ this ] ).r.length ) {			// Prevent memory leaks			jQuery( "*", this ).add(this).each(function(){				jQuery.event.remove(this);				jQuery.removeData(this);			});			if (this.parentNode)				this.parentNode.removeChild( this );		}	},	empty: function() {		// Remove element nodes and prevent memory leaks		jQuery( ">*", this ).remove();		// Remove any remaining nodes		while ( this.firstChild )			this.removeChild( this.firstChild );	}}, function(name, fn){	jQuery.fn[ name ] = function(){		return this.each( fn, arguments );	};});jQuery.each([ "Height", "Width" ], function(i, name){	var type = name.toLowerCase();	jQuery.fn[ type ] = function( size ) {		// Get window width or height		return this[0] == window ?			// Opera reports document.body.client[Width/Height] properly in both quirks and standards			jQuery.browser.opera && document.body[ "client" + name ] ||			// Safari reports inner[Width/Height] just fine (Mozilla and Opera include scroll bar widths)			jQuery.browser.safari && window[ "inner" + name ] ||			// Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode			document.compatMode == "CSS1Compat" && document.documentElement[ "client" + name ] || document.body[ "client" + name ] :			// Get document width or height			this[0] == document ?				// Either scroll[Width/Height] or offset[Width/Height], whichever is greater				Math.max(					Math.max(document.body["scroll" + name], document.documentElement["scroll" + name]),					Math.max(document.body["offset" + name], document.documentElement["offset" + name])				) :				// Get or set width or height on the element				size == undefined ?					// Get width or height on the element					(this.length ? jQuery.css( this[0], type ) : null) :					// Set the width or height on the element (default to pixels if value is unitless)					this.css( type, size.constructor == String ? size : size + "px" );	};});// Helper function used by the dimensions and offset modulesfunction num(elem, prop) {	return elem[0] && parseInt( jQuery.curCSS(elem[0], prop, true), 10 ) || 0;}var chars = jQuery.browser.safari && parseInt(jQuery.browser.version) < 417 ?		"(?:[\\w*_-]|\\\\.)" :		"(?:[\\w\u0128-\uFFFF*_-]|\\\\.)",	quickChild = new RegExp("^>\\s*(" + chars + "+)"),	quickID = new RegExp("^(" + chars + "+)(#)(" + chars + "+)"),	quickClass = new RegExp("^([#.]?)(" + chars + "*)");jQuery.extend({	expr: {		"": function(a,i,m){return m[2]=="*"||jQuery.nodeName(a,m[2]);},		"#": function(a,i,m){return a.getAttribute("id")==m[2];},		":": {			// Position Checks

⌨️ 快捷键说明

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