JS DOM: getElementById, innerHTML       jbwyatt.com

Debug this code using firebug

actually execute "Go" code here

actually execute "ClearAll" code here

actually execute "Report" code here

actually execute "ReportALL" code here (all html)

div with id='out' HERE



Write this code

Use the Tryit Editor


<html> <head> <script type="text/javascript"> function Report() { ??? WRITE THIS! } function ClearAll() { ??? WRITE THIS! } function Go() { var myNums = new Array(); var i, s; var o = document.getElementById("out"); for ( i=0; i<10; i++) myNums[i] = Math.floor( Math.random() *100); for ( i=0; i<myNums.length; i++) o.innerHTML += myNums[i] +" "; } </script> </head> <body> <div onclick="Go()">actually execute 'Go' here</div> <hr /> <div onclick="ClearAll()">actually execute 'ClearAll' here</div> <hr /> <div onclick="Report()">actually execute 'Report' here</div> <hr /> <div onclick="ReportALL()">actually execute "ReportALL" code here (all html)</div> <hr /> <div id="out"></div> </body> </html>