How to write a deferred setTimeout function?

  • 0
    I set the setTimeout function in the script, it shows what is in a certain div id.
    But it starts right after opening the page.
    How to write in the code that it would open after, for example, 20 seconds after opening the page?

    The script code itself is current:
    setTimeout(function() {
        $('#werbung').fadeOut('fast');
    }, 15000); // <-- time in milliseconds
    var seconds = 15;
    var el = document.getElementById('counter');
    function incrementSeconds() {
        seconds -= 1;
        el.innerText = 'Werbung' + '  ' + seconds;
    };
    var cancel = setInterval(incrementSeconds, 1000);
    JavaScript Anonymous, May 9, 2019

  • 1 Answers
  • 0
    wrap all this code in setTimeout
    Eden Robertson

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!