How to make JavaScript wait 5 seconds

You can use a setTimeout(), determine 5000 ms as a delay, and inside it, run your 5 seconds delayed part of code.

<script>
    setTimeout(function () {
        // do something
    }, 5000);
</script>

Example:

Print a text on the screen after 5 seconds in JavaScript.

<div id="myText"></div>

<script>
    setTimeout(function () {
        document.getElementById('myText').innerHTML = 'Done';
    }, 5000);
</script>