HTMLScriptElement: text-Eigenschaft
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.
Die text
-Eigenschaft des HTMLScriptElement
-Interfaces ist ein String, der den Textinhalt innerhalb des <script>
-Elements widerspiegelt. Sie funktioniert auf die gleiche Weise wie die Node.textContent
-Eigenschaft.
Sie spiegelt das text
-Attribut des <script>
-Elements wider.
Wert
Ein String.
Beispiele
html
<script id="el" type="text/javascript">
const num = 10;
console.log(num);
</script>
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);"
Spezifikationen
Specification |
---|
HTML # dom-script-text-dev |
Browser-Kompatibilität
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
text | ||||||||||||
Can be set with a TrustedScript instance |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- Experimental. Expect behavior to change in the future.
- User must explicitly enable this feature.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.