
在最新一集中的“剖析 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 - 文本的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号