HTMLScriptElement: text property
Baseline Widely available *
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
* Some parts of this feature may have varying levels of support.
The text
property of the HTMLScriptElement
interface is a string that reflects the text content inside the element. It acts the same way as the
Node.textContent
property.
Value
A string.
Examples
html
js
const el = document.getElementById("el");
console.log(el.text); // Output: "\n const num = 10;\n console.log(num);\n"
console.log(el.textContent); // Output: "\n const num = 10;\n console.log(num);\n"
el.text = "console.log(10);";
console.log(el.text); // Output: "console.log(10);"
console.log(el.textContent); // Output: "console.log(10);"
Specifications
Specification |
---|
HTML # dom-script-text-dev |