title: Timer runs automatically instead of on button click javascript
body: <p>I am trying to create a timer that runs once a button has been clicked and then resets once another button has been clicked. however, the timer runs automatically as soon as the application is launched and doesn't reset back to 0. Any help would be greatly appreciated. </p>
  
  <p><strong>Timer.js</strong></p>
  
  <pre><code>var sec = 0;
  
  function pad(val)
  { 
      return val &gt; 9 ? val : "0" + val; 
  }
  
  interval = setInterval( function()
  {
      document.getElementById("seconds").innerHTML=pad(++sec%60);
      document.getElementById("minutes").innerHTML=pad(parseInt(sec/60,10));
  }, 1000);
  
  function clearTimer()
  {
      clearInterval(interval);
  }
  </code></pre>
  
  <p><strong>User Scripts</strong></p>
  
  <pre><code>$(document).on("click", "#RunningTrackerBackBtn", function(evt)
  {
  
      clearTimer();
  
  });
  
      $(document).on("click", "#TrackerTest", function(evt)
  {
       /*global activate_subpage */
       activate_subpage("#TrackerPage"); 
      setInterval();        
  });
  </code></pre>
  
  <p><strong>index.html</strong></p>
  
  <pre><code>&lt;span id="minutes"&gt;00 minutes &lt;/span&gt;:&lt;span id="seconds"&gt; 00 seconds&lt;/span&gt;
  </code></pre>