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

📄 jquery-1.2.6-vsdoc-cn.js

📁 Jquery 1.2.6 最新版本的文档
💻 JS
📖 第 1 页 / 共 5 页
字号:
		///	<summary>
	    ///		将每一个匹配的元素的子内容(包括文本节点)用一个HTML结构包裹起来。
		///	</summary>
		///	<param name="html" type="String">
    	///		HTML标记代码字符串,用于动态生成元素并包装目标元素
		///	</param>
		///	<returns type="jQuery" />

		return this.each(function(){
			jQuery( this ).contents().wrapAll( html );
		});
	},

	wrap: function( html ) {
		///	<summary>
	    ///		把所有匹配的元素用其他元素的结构化标记包裹起来。
	    ///		这种包装对于在文档中插入额外的结构化标记最有用,
	    ///		而且它不会破坏原始文档的语义品质。
	    ///		这个函数的原理是检查提供的第一个元素
	    ///		(它是由所提供的HTML标记代码动态生成的),
	    ///		并在它的代码结构中找到最上层的祖先元素--这个祖先元素就是包裹元素。
	    ///		当HTML标记代码中的元素包含文本时无法使用这个函数。
	    ///		因此,如果要添加文本应该在包裹完成之后再行添加。
		///		Part of DOM/Manipulation
		///	</summary>
		///	<returns type="jQuery" />
		///	<param name="html" type="Element">
	    ///		HTML标记代码字符串,用于动态生成元素并包裹目标元素
		///	</param>
		
		return this.each(function(){
			jQuery( this ).wrapAll( html );
		});
	},

	append: function() {
		///	<summary>
	    ///		向每个匹配的元素内部追加内容。
	    ///		这个操作与对指定的元素执行appendChild方法,
	    ///		将它们添加到文档中的情况类似。
		///		Part of DOM/Manipulation
		///	</summary>
		///	<returns type="jQuery" />
		///	<param name="content" type="Content">
	    ///		要追加到目标中的内容
		///	</param>
		
		return this.domManip(arguments, true, false, function(elem){
			if (this.nodeType == 1)
				this.appendChild( elem );
		});
	},

	prepend: function() {
		///	<summary>
	    ///		向每个匹配的元素内部前置内容。
	    ///		这是向所有匹配元素内部的开始处插入内容的最佳方式。
		///		Part of DOM/Manipulation
		///	</summary>
		///	<returns type="jQuery" />
		///	<param name="" type="Content">
	    ///		要插入到目标元素内部前端的内容
		///	</param>

		return this.domManip(arguments, true, true, function(elem){
			if (this.nodeType == 1)
				this.insertBefore( elem, this.firstChild );
		});
	},

	before: function() {
		///	<summary>
	    ///		在每个匹配的元素之前插入内容。
		///		Part of DOM/Manipulation
		///	</summary>
		///	<returns type="jQuery" />
		///	<param name="" type="Content">
	    ///		在所有段落之前插入一些HTML标记代码。
		///	</param>

		return this.domManip(arguments, false, false, function(elem){
			this.parentNode.insertBefore( elem, this );
		});
	},

	after: function() {
		///	<summary>
	    ///		在每个匹配的元素之后插入内容。
		///		Part of DOM/Manipulation
		///	</summary>
		///	<returns type="jQuery" />
		///	<param name="" type="Content">
	    ///		插入到每个目标后的内容
		///	</param>

		return this.domManip(arguments, false, true, function(elem){
			this.parentNode.insertBefore( elem, this.nextSibling );
		});
	},

	end: function() {
		///	<summary>
	    ///		回到最近的一个"破坏性"操作之前。
	    ///		即,将匹配的元素列表变为前一次的状态。
	    ///		如果之前没有破坏性操作,则返回一个空集。
	    ///		所谓的"破坏性"就是指任何改变所匹配的jQuery元素的操作。
	    ///     这包括在 Traversing 中任何返回一个jQuery对象的函数--'add', 'andSelf', 'children', 'filter'
	    ///     , 'find', 'map', 'next', 'nextAll', 'not', 'parent', 'parents', 'prev', 'prevAll'
	    ///     , 'siblings' and 'slice'--再加上 Manipulation 中的 'clone'。
		///		Part of DOM/Traversing
		///	</summary>
		///	<returns type="jQuery" />

		return this.prevObject || jQuery( [] );
	},

	find: function( selector ) {
		///	<summary>
	    ///		搜索所有与指定表达式匹配的元素。
    	///		这个函数是找出正在处理的元素的后代元素的好方法。
    	///		所有搜索都依靠jQuery表达式来完成。
    	///		这个表达式可以使用CSS1-3的选择器,或简单的XPATH语法来写。
		///		Part of DOM/Traversing
		///	</summary>
		///	<returns type="jQuery" />
		///	<param name="selector" type="String">
	    ///		用于查找的表达式
		///	</param>
		///	<returns type="jQuery" />
	
		var elems = jQuery.map(this, function(elem){
			return jQuery.find( selector, elem );
		});

		return this.pushStack( /[^+>] [^+>]/.test( selector ) || selector.indexOf("..") > -1 ?
			jQuery.unique( elems ) :
			elems );
	},

	clone: function( events ) {
		///	<summary>
	    ///		克隆匹配的DOM元素并且选中这些克隆的副本。
	    ///		在想把DOM文档中元素的副本添加到其他位置时这个函数非常有用。
		///		Part of DOM/Manipulation
		///	</summary>
		///	<returns type="jQuery" />
		///	<param name="deep" type="Boolean" optional="true">
	    ///		(可选) 如果你不想克隆后代的所有节点,除了本身的元素,可以设置为False
		///	</param>

		// Do the clone
		var ret = this.map(function(){
			if ( jQuery.browser.msie && !jQuery.isXMLDoc(this) ) {
				// IE copies events bound via attachEvent when
				// using cloneNode. Calling detachEvent on the
				// clone will also remove the events from the orignal
				// In order to get around this, we use innerHTML.
				// Unfortunately, this means some modifications to
				// attributes in IE that are actually only stored
				// as properties will not be copied (such as the
				// the name attribute on an input).
				var clone = this.cloneNode(true),
					container = document.createElement("div");
				container.appendChild(clone);
				return jQuery.clean([container.innerHTML])[0];
			} else
				return this.cloneNode(true);
		});

		// Need to set the expando to null on the cloned set if it exists
		// removeData doesn't work here, IE removes it from the original as well
		// this is primarily for IE but the data expando shouldn't be copied over in any browser
		var clone = ret.find("*").andSelf().each(function(){
			if ( this[ expando ] != undefined )
				this[ expando ] = null;
		});

		// Copy the events from the original to the clone
		if ( events === true )
			this.find("*").andSelf().each(function(i){
				if (this.nodeType == 3)
					return;
				var events = jQuery.data( this, "events" );

				for ( var type in events )
					for ( var handler in events[ type ] )
						jQuery.event.add( clone[ i ], type, events[ type ][ handler ], events[ type ][ handler ].data );
			});

		// Return the cloned set
		return ret;
	},

	filter: function( selector ) {
		///	<summary>
	    ///		筛选出与指定函数返回值匹配的元素集合
	    ///		这个函数内部将对每个对象计算一次 (正如 '$.each').
    	///		如果调用的函数返回false则这个元素被删除,否则就会保留。
		///		})
		///		Part of DOM/Traversing
		///	</summary>
		///	<returns type="jQuery" />
		///	<param name="filter" type="Function">
	    ///		传递进filter的函数
		///	</param>
		///	<returns type="jQuery" />
	
		return this.pushStack(
			jQuery.isFunction( selector ) &&
			jQuery.grep(this, function(elem, i){
				return selector.call( elem, i );
			}) ||

			jQuery.multiFilter( selector, this ) );
	},

	not: function( selector ) {
		///	<summary>
    	///		将元素集合中所有与指定元素匹配的元素删除。
		///		这个方法被用来删除一个jQuery对象中一个或多个元素。
		///		Part of DOM/Traversing
		///	</summary>
		///	<param name="selector" type="jQuery">
	    ///		jQuery对象中一组要被删除的元素。
		///	</param>
		///	<returns type="jQuery" />
	
		if ( selector.constructor == String )
			// test special case where just one selector is passed in
			if ( isSimple.test( selector ) )
				return this.pushStack( jQuery.multiFilter( selector, this, true ) );
			else
				selector = jQuery.multiFilter( selector, this );

		var isArrayLike = selector.length && selector[selector.length - 1] !== undefined && !selector.nodeType;
		return this.filter(function() {
			return isArrayLike ? jQuery.inArray( this, selector ) < 0 : this != selector;
		});
	},

	add: function( selector ) {
		///	<summary>
	    ///		把与表达式匹配的元素添加到jQuery对象中。
	    ///     这个函数可以用于连接分别与两个表达式匹配的元素结果集。
		///		Part of DOM/Traversing
		///	</summary>
		///	<param name="elements" type="Element">
		///		一个或多个要添加的元素
		///	</param>
		///	<returns type="jQuery" />
	
		return this.pushStack( jQuery.unique( jQuery.merge(
			this.get(),
			typeof selector == 'string' ?
				jQuery( selector ) :
				jQuery.makeArray( selector )
		)));
	},

	is: function( selector ) {
		///	<summary>
	    ///		用一个表达式来检查当前选择的元素集合,
	    ///		如果其中至少有一个元素符合这个给定的表达式就返回true。
	    ///		如果没有元素符合,或者表达式无效,都返回'false'.
	    ///		'filter' 内部实际也是在调用这个函数,
	    ///		所以,filter()函数原有的规则在这里也适用。
		///		Part of DOM/Traversing
		///	</summary>
		///	<returns type="Boolean" />
		///	<param name="expr" type="String">
	    ///		 用于筛选的表达式
		///	</param>

		return !!selector && jQuery.multiFilter( selector, this ).length > 0;
	},

	hasClass: function( selector ) {
		///	<summary>
	    ///		检查当前的元素是否含有某个特定的类,如果有,则返回true。这其实就是 is("." + class)。
		///	</summary>
    	///	<param name="selector" type="String">用于匹配的类名</param>
    	///	<returns type="Boolean">如果有,则返回true,否则返回false.</returns>

		return this.is( "." + selector );
	},

	val: function( value ) {
		///	<summary>
	    ///		设置每一个匹配元素的值。在 jQuery 1.2, 这也可以为select元件赋值
		///		Part of DOM/Attributes
		///	</summary>
		///	<returns type="jQuery" />
		///	<param name="val" type="String">
    	///		 要设置的值。
		///	</param>

		if ( value == undefined ) {

			if ( this.length ) {
				var elem = this[0];

				// We need to handle select boxes special
				if ( jQuery.nodeName( elem, "select" ) ) {
					var index = elem.selectedIndex,
						values = [],
						options = elem.options,
						one = elem.type == "select-one";

					// Nothing was selected
					if ( index < 0 )
						return null;

					// Loop through all the selected options
					for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
						var option = options[ i ];

						if ( option.selected ) {
							// Get the specifc value for the option
							value = jQuery.browser.msie && !option.attributes.value.specified ? option.text : option.value;

							// We don't need an array for one selects
							if ( one )
								return value;

							// Multi-Selects return an array
							values.push( value );
						}
					}

					return values;

				// Everything else, we just grab the value
				} else
					return (this[0].value || "").replace(/\r/g, "");

			}

			return undefined;
		}

		if( value.constructor == Number )
			value += '';

		return this.each(function(){
			if ( this.nodeType != 1 )
				return;

			if ( value.constructor == Array && /radio|checkbox/.test( this.type ) )
				this.checked = (jQuery.inArray(this.value, value) >= 0 ||
					jQuery.inArray(this.name, value) >= 0);

			else if ( jQuery.nodeName( this, "select" ) ) {
				var values = jQuery.makeArray(value);

				jQuery( "option", this ).each(function(){
					this.selected = (jQuery.inArray( this.value, values ) >= 0 ||
						jQuery.inArray( this.text, values ) >= 0);
				});

				if ( !values.length )
					this.selectedIndex = -1;

			} else
				this.value = value;
		});
	},

	html: function( value ) {
		///	<summary>
	    ///		设置每一个匹配元素的html内容。
	    ///		这个函数不能用于XML文档。但可以用于XHTML文档。
		///		Part of DOM/Attributes
		///	</summary>
		///	<returns type="jQuery" />
		///	<param name="val" type="String">
	    ///		 用于设定HTML内容的值
		///	</param>
		
		return value == undefined ?
			(this[0] ?
				this[0].innerHTML :
				null) :
			this.empty().append( value );
	},

	replaceWith: function( value ) {
		///	<summary>
    	///		将所有匹配的元素替换成指定的HTML或DOM元素。
		///	</summary>
		///	<param name="value" type="String">
	    ///		用于将匹配元素替换掉的内容
		///	</param>
		///	<returns type="jQuery">刚替换的元素</returns>

		return this.after( value ).remove();
	},

	eq: function( i ) {
		///	<summary>
	    ///		匹配一个给定索引值的元素。
	    ///		从 0 开始计数

⌨️ 快捷键说明

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