jQuery API 返回首页目录 | jQuery API 中英文对照版
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  


相关链接
asp之家 | jQuery官方网站 | jQuery中文网 | 电子书作者网站 | 电子书作者blog