Javascript examples for DOM HTML Element:Script
Script text Property - how to get the contents of the <script> element:
<!DOCTYPE html> <html> <body> <p id="fruitdemo"></p> <button onclick="fruitFunction()">Remove the last array</button> <script id="myScript"> var fruits = ["A", "B", "C", "D"]; function fruitFunction() {/* w w w .jav a 2s . c om*/ fruits.pop(); var x = document.getElementById("fruitdemo"); x.innerHTML = fruits; } </script> <p id="contentsdemo"></p> <button onclick="textFunction()">Return contents</button> <script> function textFunction() { var x = document.getElementById("myScript").text; document.getElementById("contentsdemo").innerHTML = x; } </script> </body> </html>