jQuery API | 返回首页目录 | jQuery API 中英文对照版 |
text(val) |
text(val)
设置所有匹配元素的文本内容。这个函数与html()函数具有同样的效果。 返回值:String 参数:
设置所有段落的文本内容。 $("p").text("Some new text."); HTML 代码: <p>Test Paragraph.</p> 结果: <p>Some new text.</p> Set the text contents of all matched elements. Similar to html(), but escapes HTML (replace "<" and ">" with their HTML entities). Return value: String
Example: Sets the text of all paragraphs. $("p").text("<b>Some</b> new text.");Before: <p>Test Paragraph.</p>Result: <p><b>Some</b> new text.</p> Example: Sets the text of all paragraphs. $("p").text("<b>Some</b> new text.", true);Before: <p>Test Paragraph.</p>Result: <p><b>Some</b> new text.</p> |