In the latest episode of Anatomy of jQuery, we discuss the text()
method, and a new feature in jQuery 1.4 that you may not be aware of yet.
Subscribe to our YouTube page to watch all video tutorials!
text
jQuery source code of methodtext: 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 ); }
Remember that only users of version 1.4 or higher can pass functions to the text()
method. But that's okay; if you're still using 1.3, you really should stop! :)
The above is the detailed content of Quick Tip: Parsing jQuery - Text. For more information, please follow other related articles on the PHP Chinese website!