title: How to pause and resume a javascript timer
body: <p>I have this timer which works fine, but i need to be able to pause and resume it after that. i would appreciate it if someone could help me.</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script&gt;
  function startTimer(m,s)
      {
          document.getElementById('timer').innerHTML= m+":"+s;
          if (s==0)
              {
                 if (m == 0)
                  {
                      return;
                  }
                  else if (m != 0)
                  {
                      m = m-1;
                      s = 60;
                  }
          }
      s = s-1;
      t=setTimeout(function(){startTimer(m,s)},1000);
  }
  
  
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;button onClick = "startTimer(5,0)"&gt;Start&lt;/button&gt;
  
  &lt;p id = "timer"&gt;00:00&lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>