-1

Possible Duplicate:
jQuery: text() vs html()?

What's the difference between text and html() in jquery?

Community
  • 1
  • 1
Steffan Harris
  • 9,106
  • 30
  • 75
  • 101

1 Answers1

4

Unlike the .html() method, .text() 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. (Due to variations in the HTML parsers in different browsers, the text returned may vary in newlines and other white space.)

Source: http://api.jquery.com/text/

This answer was clear from the API docs, though.

If you are ever curious how one or another function works, head to http://api.jquery.com/[function-name]. If the answer is not in the main text, look through comments. If you haven't found your answer yet, spend at least 2 minutes using Google. If you haven't found your answer yet, ask in stackoverflow.

Gajus
  • 69,002
  • 70
  • 275
  • 438