Because when I put document.write
inside for
it lists right and in innerHTML
it only sends the last position in div
? I wanted to know how I can for
print within div
from start to end of list, but I'm not getting it.
<head>
<meta charset=UTF-8/>
<link rel="stylesheet" type="text/css" href="main.css">
<script type="text/javascript" src="main.js"></script>
</head>
<body>
<input type="text" id="text">
<input type="button" id="click" value="click">
<input type="button" id="mos" value="mostrar">
<div id="div"></div>
</body>
<script>
var lista = [];
window.onload = function() {
var text = document.getElementById("text");
var click = document.getElementById("click");
var mos = document.getElementById("mos");
var div = document.getElementById("div");
click.onclick = function() {
lista.push(text.value + " <
br / > "); } mos.onclick=function(){ for (var i = 0; i <
lista.length; i++) {
div.innerHTML = lista[i];
}
}
}
</script>