Quick Tip: Dissecting jQuery – Text
Tutorial Details
- Topic: jQuery Source Code
- Estimated Difficulty: Intermediate
- Format: 7 Minute Screencast
Download Source Files
In this latest episode of “Dissecting jQuery,” we’ll discuss the text() method, as well as a new feature, as of jQuery 1.4, that you may not be aware of yet.
Premium Members: Download this Video ( Must be logged in)
Subscribe to our YouTube page to watch all of the video tutorials!
jQuery Source for the text Method
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 );
}
Keep in mind that the ability to pass a function to the text() method is only available, via the user of version 1.4 or higher. But that’s no problem; and if you’re still using 1.3, you should really stop! :)
Other Episodes in the “Dissecting jQuery” Series
Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
- Shadow
- Avinash
- Edu
- Martin Førre
- http://www.wdonline.com Jeremy
- http://www.jQuerios.com jQuerios
- http://jeroenverfallie.com Jeroen
- http://jacobdubail.com Jacob
- http://poetro.hu/ Peter Galiba
- Leigh Kaszick
- Proxi
- http://www.totalmedial.de Proxi
- Proxi
- Leigh Kaszick
- erminio ottone
- Nasi
- http://www.aediscreative.com Christopher
- http://tj.abderrahmane.com Abderrahmane TJ
- Cusco
- http://dejoe.tumblr.com Joe
