To delay javascript function call using jquery

Posted by Mohan Ram on Stack Overflow See other posts from Stack Overflow or by Mohan Ram
Published on 2011-03-16T07:46:44Z Indexed on 2011/03/16 8:10 UTC
Read the original article Hit count: 188

Filed under:
|

CODES:

    $().ready(function(){

    function sample()
    {
       alert("This is sample function");
    }

   $("#button").click(function(){
    t=setTimeout("sample()",2000);
    });

    });

HTML:

<input type="button" name="button" id="button" value="Call sample function with delay">

Once i click button sample function is not called with a delay of 2 seconds. I dont know whats wrong. Please notify me how to do this

Question: To call javascript function using setTimeout via jquery

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery