Home  >  Article  >  CMS Tutorial  >  Quick Tip: Parsing jQuery - Text

Quick Tip: Parsing jQuery - Text

WBOY
WBOYOriginal
2023-08-29 21:13:15584browse

快速技巧:解析jQuery - 文本

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.

Premium Members: Download this video (must log in)

Subscribe to our YouTube page to watch all video tutorials!

text jQuery source code of 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 );
	}

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! :)


Other chapters in the "Anatomy of jQuery" series

  1. filter
  2. Grep

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn