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

📄 jquery.js

📁 自己写的一个struts+spring+hibernate测试程序
💻 JS
📖 第 1 页 / 共 5 页
字号:
	 * @cat JavaScript	 */	grep: function(elems, fn, inv) {		// If a string is passed in for the function, make a function		// for it (a handy shortcut)		if ( typeof fn == "string" )			fn = new Function("a","i","return " + fn);		var result = [];		// Go through the array, only saving the items		// that pass the validator function		for ( var i = 0, el = elems.length; i < el; i++ )			if ( !inv && fn(elems[i],i) || inv && !fn(elems[i],i) )				result.push( elems[i] );		return result;	},	/**	 * Translate all items in an array to another array of items.	 *	 * The translation function that is provided to this method is 	 * called for each item in the array and is passed one argument: 	 * The item to be translated.	 *	 * The function can then return the translated value, 'null'	 * (to remove the item), or  an array of values - which will	 * be flattened into the full array.	 *	 * @example $.map( [0,1,2], function(i){	 *   return i + 4;	 * });	 * @result [4, 5, 6]	 * @desc Maps the original array to a new one and adds 4 to each value.	 *	 * @example $.map( [0,1,2], function(i){	 *   return i > 0 ? i + 1 : null;	 * });	 * @result [2, 3]	 * @desc Maps the original array to a new one and adds 1 to each	 * value if it is bigger then zero, otherwise it's removed-	 * 	 * @example $.map( [0,1,2], function(i){	 *   return [ i, i + 1 ];	 * });	 * @result [0, 1, 1, 2, 2, 3]	 * @desc Maps the original array to a new one, each element is added	 * with it's original value and the value plus one.	 *	 * @name $.map	 * @type Array	 * @param Array array The Array to translate.	 * @param Function fn The function to process each item against.	 * @cat JavaScript	 */	map: function(elems, fn) {		// If a string is passed in for the function, make a function		// for it (a handy shortcut)		if ( typeof fn == "string" )			fn = new Function("a","return " + fn);		var result = [], r = [];		// Go through the array, translating each of the items to their		// new value (or values).		for ( var i = 0, el = elems.length; i < el; i++ ) {			var val = fn(elems[i],i);			if ( val !== null && val != undefined ) {				if ( val.constructor != Array ) val = [val];				result = result.concat( val );			}		}		return result;	}});/** * Contains flags for the useragent, read from navigator.userAgent. * Available flags are: safari, opera, msie, mozilla * * This property is available before the DOM is ready, therefore you can * use it to add ready events only for certain browsers. * * There are situations where object detections is not reliable enough, in that * cases it makes sense to use browser detection. Simply try to avoid both! * * A combination of browser and object detection yields quite reliable results. * * @example $.browser.msie * @desc Returns true if the current useragent is some version of microsoft's internet explorer * * @example if($.browser.safari) { $( function() { alert("this is safari!"); } ); } * @desc Alerts "this is safari!" only for safari browsers * * @property * @name $.browser * @type Boolean * @cat JavaScript */ /* * Whether the W3C compliant box model is being used. * * @property * @name $.boxModel * @type Boolean * @cat JavaScript */new function() {	var b = navigator.userAgent.toLowerCase();	// Figure out what browser is being used	jQuery.browser = {		version: b.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)[1],		safari: /webkit/.test(b),		opera: /opera/.test(b),		msie: /msie/.test(b) && !/opera/.test(b),		mozilla: /mozilla/.test(b) && !/(compatible|webkit)/.test(b)	};	// Check to see if the W3C box model is being used	jQuery.boxModel = !jQuery.browser.msie || document.compatMode == "CSS1Compat";};/** * Get a set of elements containing the unique parents of the matched * set of elements. * * You may use an optional expression to filter the set of parent elements that will match. * * @example $("p").parent() * @before <div><p>Hello</p><p>Hello</p></div> * @result [ <div><p>Hello</p><p>Hello</p></div> ] * @desc Find the parent element of each paragraph. * * @example $("p").parent(".selected") * @before <div><p>Hello</p></div><div class="selected"><p>Hello Again</p></div> * @result [ <div class="selected"><p>Hello Again</p></div> ] * @desc Find the parent element of each paragraph with a class "selected". * * @name parent * @type jQuery * @param String expr (optional) An expression to filter the parents with * @cat DOM/Traversing *//** * Get a set of elements containing the unique ancestors of the matched * set of elements (except for the root element). * * The matched elements can be filtered with an optional expression. * * @example $("span").parents() * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html> * @result [ <body>...</body>, <div>...</div>, <p><span>Hello</span></p> ] * @desc Find all parent elements of each span. * * @example $("span").parents("p") * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html> * @result [ <p><span>Hello</span></p> ] * @desc Find all parent elements of each span that is a paragraph. * * @name parents * @type jQuery * @param String expr (optional) An expression to filter the ancestors with * @cat DOM/Traversing *//** * Get a set of elements containing the unique next siblings of each of the * matched set of elements. * * It only returns the very next sibling for each element, not all * next siblings. * * You may provide an optional expression to filter the match. * * @example $("p").next() * @before <p>Hello</p><p>Hello Again</p><div><span>And Again</span></div> * @result [ <p>Hello Again</p>, <div><span>And Again</span></div> ] * @desc Find the very next sibling of each paragraph. * * @example $("p").next(".selected") * @before <p>Hello</p><p class="selected">Hello Again</p><div><span>And Again</span></div> * @result [ <p class="selected">Hello Again</p> ] * @desc Find the very next sibling of each paragraph that has a class "selected". * * @name next * @type jQuery * @param String expr (optional) An expression to filter the next Elements with * @cat DOM/Traversing *//** * Get a set of elements containing the unique previous siblings of each of the * matched set of elements. * * Use an optional expression to filter the matched set. * * 	Only the immediately previous sibling is returned, not all previous siblings. * * @example $("p").prev() * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p> * @result [ <div><span>Hello Again</span></div> ] * @desc Find the very previous sibling of each paragraph. * * @example $("p").prev(".selected") * @before <div><span>Hello</span></div><p class="selected">Hello Again</p><p>And Again</p> * @result [ <div><span>Hello</span></div> ] * @desc Find the very previous sibling of each paragraph that has a class "selected". * * @name prev * @type jQuery * @param String expr (optional) An expression to filter the previous Elements with * @cat DOM/Traversing *//** * Get a set of elements containing all of the unique siblings of each of the * matched set of elements. * * Can be filtered with an optional expressions. * * @example $("div").siblings() * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p> * @result [ <p>Hello</p>, <p>And Again</p> ] * @desc Find all siblings of each div. * * @example $("div").siblings(".selected") * @before <div><span>Hello</span></div><p class="selected">Hello Again</p><p>And Again</p> * @result [ <p class="selected">Hello Again</p> ] * @desc Find all siblings with a class "selected" of each div. * * @name siblings * @type jQuery * @param String expr (optional) An expression to filter the sibling Elements with * @cat DOM/Traversing *//** * Get a set of elements containing all of the unique children of each of the * matched set of elements. * * This set can be filtered with an optional expression that will cause * only elements matching the selector to be collected. * * @example $("div").children() * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p> * @result [ <span>Hello Again</span> ] * @desc Find all children of each div. * * @example $("div").children(".selected") * @before <div><span>Hello</span><p class="selected">Hello Again</p><p>And Again</p></div> * @result [ <p class="selected">Hello Again</p> ] * @desc Find all children with a class "selected" of each div. * * @name children * @type jQuery * @param String expr (optional) An expression to filter the child Elements with * @cat DOM/Traversing */jQuery.each({	parent: "a.parentNode",	parents: "jQuery.parents(a)",	next: "jQuery.nth(a,2,'nextSibling')",	prev: "jQuery.nth(a,2,'previousSibling')",	siblings: "jQuery.sibling(a.parentNode.firstChild,a)",	children: "jQuery.sibling(a.firstChild)"}, function(i,n){	jQuery.fn[ i ] = function(a) {		var ret = jQuery.map(this,n);		if ( a && typeof a == "string" )			ret = jQuery.multiFilter(a,ret);		return this.pushStack( ret );	};});/** * Append all of the matched elements to another, specified, set of elements. * This operation is, essentially, the reverse of doing a regular * $(A).append(B), in that instead of appending B to A, you're appending * A to B. * * @example $("p").appendTo("#foo"); * @before <p>I would like to say: </p><div id="foo"></div> * @result <div id="foo"><p>I would like to say: </p></div> * @desc Appends all paragraphs to the element with the ID "foo" * * @name appendTo * @type jQuery * @param <Content> content Content to append to the selected element to. * @cat DOM/Manipulation * @see append(<Content>) *//** * Prepend all of the matched elements to another, specified, set of elements. * This operation is, essentially, the reverse of doing a regular * $(A).prepend(B), in that instead of prepending B to A, you're prepending * A to B. * * @example $("p").prependTo("#foo"); * @before <p>I would like to say: </p><div id="foo"><b>Hello</b></div> * @result <div id="foo"><p>I would like to say: </p><b>Hello</b></div> * @desc Prepends all paragraphs to the element with the ID "foo" * * @name prependTo * @type jQuery * @param <Content> content Content to prepend to the selected element to. * @cat DOM/Manipulation * @see prepend(<Content>) *//** * Insert all of the matched elements before another, specified, set of elements. * This operation is, essentially, the reverse of doing a regular * $(A).before(B), in that instead of inserting B before A, you're inserting * A before B. * * @example $("p").insertBefore("#foo"); * @before <div id="foo">Hello</div><p>I would like to say: </p> * @result <p>I would like to say: </p><div id="foo">Hello</div> * @desc Same as $("#foo").before("p") * * @name insertBefore * @type jQuery * @param <Content> content Content to insert the selected element before. * @cat DOM/Manipulation * @see before(<Content>) *//** * Insert all of the matched elements after another, specified, set of elements. * This operation is, essentially, the reverse of doing a regular * $(A).after(B), in that instead of inserting B after A, you're inserting * A after B. * * @example $("p").insertAfter("#foo"); * @before <p>I would like to say: </p><div id="foo">Hello</div> * @result <div id="foo">Hello</div><p>I would like to say: </p> * @desc Same as $("#foo").after("p") * * @name insertAfter * @type jQuery * @param <Content> content Content to insert the selected element after. * @cat DOM/Manipulation * @see after(<Content>) */jQuery.each({	appendTo: "append",	prependTo: "prepend",	insertBefore: "before",	insertAfter: "after"}, function(i,n){	jQuery.fn[ i ] = function(){		var a = arguments;		return this.each(function(){			for ( var j = 0, al = a.length; j < al; j++ )				jQuery(a[j])[n]( this );		});	};});/** * Remove an attribute from each of the matched elements. * * @example $("input").removeAttr("disabled") * @before <input disabled="disabled"/> * @result <input/> * * @name removeAttr * @type jQuery * @param String name The name of the attribute to remove. * @cat DOM/Attributes *//** * Adds the specified class(es) to each of the set of matched elements. * * @example $("p").addClass("selected") * @before <p>Hello</p> * @result [ <p class="selected">Hello</p> ] * * @example $("p").addClass("selected highlight") * @before <p>Hello</p> * @result [ <p class="selected highlight">Hello</p> ] * * @name addClass * @type jQuery * @param String class One or more CSS classes to add to the elements * @cat DOM/Attributes * @see removeClass(String) *//** * Removes all or the specified class(es) from the set of matched elements. * * @example $("p").removeClass() * @before <p class="selected">Hello</p> * @result [ <p>Hello</p> ] * * @example $("p").removeClass("selected") * @before <p class="selected first">Hello</p> * @result [ <p class="first">Hello</p> ] * * @example $("p").removeClass("selected highlight") * @before <p class="highlight selected first">Hello</p> * @result [ <p class="first">Hello</p> ] * * @name removeClass * @type jQuery * @param String class (optional) One or more CSS classes to remove from the elements * @cat DOM/Attributes * @see addClass(String) *//** * Adds the specified class if it is not present, removes it if it is * present. * * @example $("p").toggleClass("selected") * @before <p>Hello</p>

⌨️ 快捷键说明

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