### [快速技巧:解析jQuery - 文本](https://www.prosaas.cn/article/6565) **Published:** 2023-08-29T13:13:15 **Author:** 5201314 **Excerpt:** 在最新一集中的“剖析 jQuery”中,我们将讨论 方法,以及 jQuery 1.4 中您可能还不知道的一项新… ![](//zhiqipro.oss-cn-beijing.aliyuncs.com/2023/12/20231212125128932.jpg) 在最新一集中的“剖析 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 - 文本的详细内容,更多请关注知企PROSAAS其它相关文章! **Tags:** jquery **Categories:** WordPress ---