快速提示:解析jQuery - 文本

WBOY
WBOY 原创
2023-08-30 08:25:02 871浏览

快速提示:解析jQuery - 文本

在最新一集中的“剖析 jQuery”中,我们将讨论 text() 方法,以及 jQuery 1.4 中您可能还不知道的一项新功能。

高级会员:下载此视频(必须登录)

订阅我们的 YouTube 页面以观看所有视频教程!

text 方法的 jQuery 源代码

text: function( text ) {
		if ( jQuery.isFunction(text) ) {
			return this.each(function(i) {
				var self = jQuery(this);
				self.text( text.call(this, i, self.text()) );
			});
		}

		if ( typeof text !== "object" && text !== undefined ) {
			return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
		}

		return jQuery.text( this );
	}

请记住,只有 1.4 或更高版本的用户才能将函数传递给 text() 方法。但这没问题;如果您仍在使用 1.3,您真的应该停止使用! :)


“剖析 jQuery”系列中的其他章节

  1. 过滤器
  2. 格列普

以上就是快速提示:解析jQuery - 文本的详细内容,更多请关注php中文网其它相关文章!

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。