jQuery API jQuery API 中英文对照版 - jQuery在线查询手册
text
text()

取得所有匹配元素的内容。结果是由所有匹配元素包含的文本内容组合起来的文本。这个方法对HTML和XML文档都有效。

返回值:String

示例:

取得所有段落中文本内容的组合。

$("p").text();

HTML 代码:

<p><b>Test</b> Paragraph.</p><p>Paraparagraph</p>

结果:

Test Paragraph.Paraparagraph

 
text()

Get the text contents of all matched elements. The result is a string that contains the combined text contents of all matched elements. This method works on both HTML and XML documents.

Return value: String
Example:

Gets the concatenated text of all paragraphs

 $("p").text();  

Before:

 <p><b>Test</b> Paragraph.</p><p>Paraparagraph</p>  
Result:
 Test Paragraph.Paraparagraph