出于这些目的,我不确定是否要发送实际的HTML值,因为它将有HTML标记。在
文件。在In an HTML document, .html() can be used to get the contents of any
element. If the selector expression matches more than one element,
only the first match will have its HTML content returned. Consider
this code:$( "div.demo-container" ).html();In order for the following 's content to be retrieved, it would
have to be the first one with class="demo-container" in the document:
^{pr2}$
The result would look like this:
但是,正如您所看到的,HTML标记仍然存在。在
您应该使用text()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.) Consider the following HTML:
- list item 1
- list item 2
代码$( "div.demo-container" ).text()将产生以下结果:Demonstration Box list item 1 list item 2