/

HTML / CSS / JavaScript Tutorial

JavaScript script object property: text

[this page | pdf | back links]

The text property of the JavaScript DOM object corresponding to the HTML <script> element sets / returns the contents of all child text nodes of the script.

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
table,td,tr,th,caption {border: thin solid black; border-collapse: collapse;}
</style>
</head>
<body>
<table >
  <tr><td>script text</td><td id="x1"></td></tr>
</table>

<script id="element">
var x = document.getElementById("element");
document.getElementById("x1").innerHTML = x.text;
</script>

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | JavaScript DOM (and BOM)


Desktop view | Switch to Mobile