You are here: Reference > JavaScript > client-side > HTML DOM > properties > text (script, title, CommentNode, ...)
text property (script, title, CommentNode, ...)
Sets or returns a string that corresponds the contents of the element.
The text property for CommentNode elements is only supported by Internet Explorer.
If you need the text content of a CommentNode or TextNode, use the data or nodeValue property.
Syntax:
You can find the related objects in the Supported by objects section below.
This property is read/write.
Possible values:
String that sets or retrieves the text content of the object.
Default: this property has no default value.
Example HTML code 1:
This example illustrates the use of the text property:
|
||||
<head> <script type="text/javascript"> function GetText () { var scripts = document.getElementsByTagName ("script"); alert (scripts[0].text); } </script> </head> <body> <button onclick="GetText ();">Get the contents of the script tag!</button> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
Related pages:
External links:
User Contributed Comments