title: How to create a stopwatch using JavaScript?
body: <pre><code>if(stopwatch &gt;= track[song].duration)
  </code></pre>
  
  <p><code>track[song].duration</code> finds the duration of a soundcloud track.</p>
  
  <p>I am looking to create a stopwatch function that starts counting milliseconds when you click on the <code>swap</code> ID <code>stopwatch</code> so that when the function has been "clicked" for a certain amount of time the if function will do something. In my case replace an image. And also that the function will reset it itself when clicked again.</p>
  
  <p>so like <code>stopwatch</code> = <code>current time</code> - <code>clicked time</code> How can I set up the <code>clicked time</code></p>
  
  <p><code>current time</code> = <code>new Date().getTime();</code> ? And is this in milliseconds?</p>
  
  <pre><code>$('#swap').click(function()...
  </code></pre>