jQuery text() Method

Last Updated Jul 25, 2015, 11:00:06 PM





jQuery text() Method

jQuery text() method sets or returns the text content of the selected HTMLelements.

Syntax

Apart from the html() method, the .text() method also can be used in both XML and HTML documents. The result of the .text() method is a string containing the combined text of all matched elements.

Note:When this method is used to return content, it returns the text content of all matched HTMLelements .

When this method is used to set content, it overwrites the content of ALL matched HTML elements.

Example

The above jquery text() method example will produce the following output


jQuery text() method
Try It Now

Other Advanced jQuery DOM topics you might want to learn
jQuery Basic DOM Methods

jQuery DOM Reference

jQuery DOM Removal

jQuery DOM Insertion Inside

jQuery DOM Insertion Outside

jQuery DOM Insertion Around

Sources and Credits

The content and methods in the tutorial has been referred and updated with jQuery API and The jQuery Foundation

Last Updated Jul 25, 2015, 11:00:06 PM