html - Count to 100 using Javascript (in a div) -


this question has answer here:

i wanne count 100 in div using javascript. why comes last number.

here code:

function test() {  	for (var x = 1; x < 101; x++) {  		document.getelementbyid("demo").innerhtml = (x + "<br />");  	}  }function leer() {  	document.getelementbyid("demo").innerhtml = "delete"    }
<html>  <head>  <script src="function.js"></script>  </head>  <body>  <button type="button" onclick="test()">100</button>  <button type="button" onclick="leer()">delete</button>  <div id="demo">  </div>  </body>  </html>

change document.getelementbyid("demo").innerhtml += (x + "<br />"); line

function test() {  	for (var x = 1; x < 101; x++) {  		document.getelementbyid("demo").innerhtml += (x + "<br />");  	}  }function leer() {  	document.getelementbyid("demo").innerhtml = "delete"    }
<html>  <head>  <script src="function.js"></script>  </head>  <body>  <button type="button" onclick="test()">100</button>  <button type="button" onclick="leer()">delete</button>  <div id="demo">  </div>  </body>  </html>


Comments

Popular posts from this blog

'hasOwnProperty' in javascript -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -

How to understand 2 main() functions after using uftrace to profile the C++ program? -