jquery text()
.text()
This method does not accept any arguments.
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.)
.text()获取标签里的文本内容,.html()会连同标签一起获取
The .text() method cannot be used on form inputs or scripts. To set or get the text value of input or textarea elements, use the .val() method. To get the value of a script element, use the .html() method.
As of jQuery 1.4, the .text() method returns the value of text and CDATA nodes as well as element nodes.
.text( textString )
Description: Set the content of each element in the set of matched elements to the specified text.
textString
Type: String
A string of text to set as the content of each matched element.
.text( function(index, text) )
function(index, text)
Type: Function()
A function returning the text content to set. Receives the index position of the element in the set and the old text value as arguments.
Unlike the .html() method, .text() can be used in both XML and HTML documents.
We need to be aware that this method escapes the string provided as necessary so that it will render correctly in HTML. To do so, it calls the DOM method .createTextNode(), does not interpret the string as HTML.
.text()
This method does not accept any arguments.
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.)
.text()获取标签里的文本内容,.html()会连同标签一起获取
The .text() method cannot be used on form inputs or scripts. To set or get the text value of input or textarea elements, use the .val() method. To get the value of a script element, use the .html() method.
As of jQuery 1.4, the .text() method returns the value of text and CDATA nodes as well as element nodes.
.text( textString )
Description: Set the content of each element in the set of matched elements to the specified text.
textString
Type: String
A string of text to set as the content of each matched element.
.text( function(index, text) )
function(index, text)
Type: Function()
A function returning the text content to set. Receives the index position of the element in the set and the old text value as arguments.
Unlike the .html() method, .text() can be used in both XML and HTML documents.
We need to be aware that this method escapes the string provided as necessary so that it will render correctly in HTML. To do so, it calls the DOM method .createTextNode(), does not interpret the string as HTML.