HTML DOM Script text attributes
Examples
Get Content <script> element:
var x = document.getElementById("myScript").text
x The output is:
document.write("Hello World!");
try it"
Definition and Usage
text property sets or returns the contents of <script> element.
Browser Support
All major browsers support the text attribute.
grammar
Returns text attributes:
scriptObject .text
Setting text attributes:
scriptObject .text=contents
Property Value
值 | 描述 |
---|---|
contents | 规定脚本的内容。 |
technical details
return value: | String that represents the contents of the script. Content returns <script> element in all child text nodes (other nodes, such as comments or elements are ignored). |
---|
More examples
Examples
Another example - Get content <script> element:
var x = document.getElementById("myScript").text
x The output is:
var fruits = ["Banana", "Orange", "Apple",
"Mango"]; function fruitFunction() { fruits.pop(); var x =
document.getElementById("fruitdemo"); x.innerHTML=fruits; }
try it"