Javascript examples for DOM:Document getElementById
Set value to an element returned from document.getElementById(...)
<html> <head> <script> window.onload = function () {// w w w.j ava 2s .com var x = 5; var y = 6; var z = x + y; document.getElementById("add").innerHTML = z; }; </script> </head> <body> <h1>Demo</h1> <div id="demo"> Addition of 5 and 6 is <span id="add"></span> </div> </body> </html>