Home > Web Front-end > JS Tutorial > Quick Tip: Parsing jQuery - Text

Quick Tip: Parsing jQuery - Text

WBOY
Release: 2023-08-30 08:25:02
Original
1274 people have browsed it

快速提示:解析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 );
	}
Copy after login

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!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template