Using the code the way you've written it, isn't going to work.
Instead, I recommend using css styling to accomplish what you want.
This is a general idea of how I would do it (give or take).
<script>
// Code goes here
var b = document.body;
function text() {
var testone=Math.floor(Math.random()*9);
var d = document.createElement('div');
d.innerHTML += '<span>' + testone + '</span> ';
d.innerHTML += '<span style="display:none">' + testone + '</span>';
setTimeout(function() {
var childs = d.children;
for(i = 0; i < childs.length; ++i) {
childs[i].style.display = 'inline';
}
},500);
b.appendChild(d);
}
setInterval(text,100);
</script>
NOTE for the above code to function properly, the script tag will have to execute inside the body tag (otherwise document.body will be null).
This plunkr shows the code in action.
http://plnkr.co/edit/JNJpaH2qEDwEl56C9YpU
I also took a few liberties, such as using a <div>
instead of <br>
, and I'm not worried about efficiency of reflowing dom every 1/2 second.