l3ny
l3ny

Reputation: 355

Wait one minute before running the function?

I want to give it a one minute wait before it runs.

    function hideWidget() {
        selWidget.style.visibility = "hidden";
    }
    document.querySelector('.fkr').addEventListener('mouseout', function (e) {
        hideWidget()
    }, false);

I tried a few referent ways without success, thank you in advance. eg.. setTimeout(hideWidget, 200);

Upvotes: 0

Views: 5046

Answers (1)

php_nub_qq
php_nub_qq

Reputation: 16045

You were on the right path. It looks like you just needed to figure out how to set the length of the timeout. The second parameter is what is determining how long to wait before executing the function and it is measured in miliseconds. 1 milisecond is equal to 0.001 seconds, so in order to get 60 seconds you need to multiply 1 by 1000 by 60. So the code would look like

setTimeout(hideWidget, 60000);

Upvotes: 3

Related Questions