This is somewhat of a hypothetical question as it is something I have been breaking my head about whether it's possible or not (either in php or in java-script or any other way):
Suppose I have an array of 1,2,3,4,5,6,7,8,9,0.
In the situation I am thinking about I was wondering whether it's possible to display them in a list visually building up like this:
1 (1 second interval)
2 (1 second interval)
3 (1 second interval)
...and so on until the full list of all ten items is displayed after 10-11 seconds.
This is actually a pure theoretical question as I am not currently struggling with it while coding, hence I am not including any code-examples.
I was just wondering, philosophizing if you like, whether this is possible instead of showing the whole array all at once? To be honest, I've never come across anything that said it was possible. Thanks a million!
You should at least post what you have tried so far, here is some basic example
var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
var elem = document.getElementById('pr');
function print(array, el) {
var i = 0;
var func = setInterval(function() {
el.innerHTML += '<br>' + array[i];
i++;
if (i >= array.length) {
clearInterval(func);
}
}, 1000);
}
print(arr, elem);
<div id="pr">
</div>
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다