Created
January 19, 2023 04:35
-
-
Save eboominathan/93d3320b751cf4133fc08ac9bababe56 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
</head> | |
<body> | |
<div class="main"> | |
<div id="one">-</div> | |
<div id="two">-</div> | |
<div id="three">-</div> | |
<div id="four">-</div> | |
</div> | |
</body> | |
<script src="jquery.min.js"></script> | |
<script> | |
var myArray = [{ | |
'a1': 1, | |
'a2': 2, | |
'a3': 3, | |
'a4': 4 | |
}, | |
{ | |
'a1': 5, | |
'a2': 6, | |
'a3': 7, | |
'a4': 8 | |
}, | |
{ | |
'a1': 9, | |
'a2': 10, | |
'a3': 11, | |
'a4': 12 | |
}, | |
{ | |
'a1': 13, | |
'a2': 14, | |
'a3': 15, | |
'a4': 16 | |
}, | |
]; | |
function getData(array, i) { | |
console.log(array[i]); | |
} | |
function init(array) { | |
var i = 0; | |
var interval = setInterval(() => { | |
if (array[i]) { | |
// console.log(array[i]); | |
if (array[i].a1) { | |
$('#one').text(array[i].a1); | |
} | |
if (array[i].a2) { | |
$('#two').text(array[i].a2); | |
} | |
if (array[i].a3) { | |
$('#three').text(array[i].a3); | |
} | |
if (array[i].a4) { | |
$('#four').text(array[i].a4); | |
} | |
i++; | |
} else { | |
i = 0; | |
} | |
}, 200); | |
setTimeout(function( ) { clearInterval( interval ); }, 5000); | |
} | |
init(myArray); | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment