Javascript examples for DOM HTML Element:Div
Use div to show function result
<html> <head></head> <body> <div id="resultsDiv"> <h3>Results Here:</h3> </div> <script type="text/javascript"> var sum = 0;//from w ww . j a v a 2 s. c om var resultsDiv = document.getElementById('resultsDiv'); for (var i = 0; i < 1000; i++) { if (i % 3 === 0 || i % 5 === 0 || i % 7 === 0) { sum += i; } resultsDiv.innerHTML += 'The sum is' + " " + sum + "<br />"; } </script> </body> </html>