title: To delay JavaScript function call using jQuery
body: <h3>JavaScript:</h3>
  <pre><code>$(document).ready(function(){
      
      function sample() {
         alert(&quot;This is sample function&quot;);
      }
   
      $(&quot;#button&quot;).click(function(){
          t = setTimeout(&quot;sample()&quot;,2000);
      });
          
  });
  </code></pre>
  <p><strong>HTML:</strong></p>
  <pre><code>&lt;input type=&quot;button&quot; id=&quot;button&quot; value=&quot;Call sample function with delay&quot;&gt;
  </code></pre>
  <p>Once I click the button, <code>sample()</code> function is not called with a delay of 2 seconds. I don't know what's wrong.</p>
  <p>How to call JavaScript function using <code>setTimeout()</code> via jQuery?</p>