How to add time to this code! Automatically switch to the next random picture

< script language= "JavaScript" type= "text/javascript" >
/ / Random image code
tips = new Array (3);
tips [0] =" ";
tips [1] =" ";
tips [2] =" index = Math.floor (Math.random () * tips.length);
document.write (tips [tips.length]);
< / script >

how to add time to this code! Automatically switch to the next random picture

May.22,2021


< html lang= "en" >
< head >

<meta charset="UTF-8">
<title>Document</title>

< / head >
< body >

<img id='img' src="" alt="">
<script>
    window.onload = function () {
        var imgDom = document.getElementById('img')
        var imgArr = ['tiggo32.png','tiggo32.png','tiggo32.png']

        function setImg (){
            var index = Math.floor(Math.random() * tips.length)
            imgDom.src = imgArr[index]
        }

        setImg()
        setInterval( function (){
            setImg()
        }, 5000)

    }
</script>

< / body >
< / html >


you shouldn't write like this, you're thinking wrong.

var a = ["x.jpg", "y.jpg", "q.jpg"];
var img=new Image ();
setInterval (function () {

         img.src=a[Math.floor(Math.random()*a.length)];

document.getBytabNames ("body") [0] .addChilen (img)

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b38797-2b893.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b38797-2b893.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?