Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body>
<h1>The Document Object</h1>
<h2>The scripts Property</h2>
<script id="myFirstScript">
document.write("Hello World!");
</script>
<p>Display the id of each script element:</p>
<p id="demo"></p>
<script id="mySecondScript">
const collection = document.scripts;
let text = "";
for (let i = 0; i < collection.length; i++) {
  text += collection[i].id + "<br>";
}
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>