91-9990449935 0120-4256464 |
jQuery text()The jQuery text() method is used to set or return the text content of the selected elements. To return content: When this method is used to return content, it returns the combined text content of all matched elements without the HTML markup. To set content: When this method is used to set content, it overwrites the content of all matched elements. Difference between jQuery text() method and jQuery html() methodSometimes, this confusion is occurred because both of the methods are used to set or return the html content. But, the jQuery text() method is different from html() method. Following is the main differences:
Syntax: To return text content: To set text content: To set text content using a function: Parameters of jQuery text() method
Example of jQuery text() methodLet's take an example to demonstrate the effect of jQuery text() method. A simple example to return content: Test it Now Output: Hello! javatpoint.com Hello! javatpoint.com Another example of jQuery text() methodAn example for set content: Test it NowOutput: Hello Guys! Looking for online training....
Next TopicjQuery val()
|