2

I have a welcome popup on my home page site.

I have this Javascript

<script type="text/javascript">
    $(document).ready(function () {
        $("#div-welcome").dialog({
              width: 'auto',
              height: 'auto',
              modal: true
        });
    });
</script>

How can I set a delay of 3 seconds? I tried with setTime function but that didn't work. Maybe I put it in the wrong place. Thank you! AVersa

1

2 Answers 2

1

Use setTimeout.

The setTimeout() method calls a function or evaluates an expression after a specified number of milliseconds.

Write this:

$(document).ready(function () {
    setTimeout(function(){
        $("#div-welcome").dialog({
            width: 'auto',
            height: 'auto',
            modal: true
        });
    },3000);
});
Sign up to request clarification or add additional context in comments.

Comments

0
$(document).ready(function () {
    window.setTimeout(function () {
        $("#div-welcome").dialog({
              width: 'auto',
              height: 'auto',
              modal: true
        });
    }, 3000);
});

1 Comment

Np! :) By the way, please accept an answer if you're satisfied.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.