title: lightweight metronome does not work?
body: <p>i'm trying to make here a simple visual metronome with only javascript and Jquery.
  it does not seem to work well and i can't figure out why.</p>
  
  <p>Do you ?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function metronome() {
                          
               
               var slidevalue = document.getElementById('speed').value;
               var delay = 1000 / ((slidevalue * 9) / 60);
               var timer= setInterval(function(){ 
                    
          
         setTimeout(function(){ $("#metronome").css({"background-color":"red"});},delay);
         setTimeout(function(){ $("#metronome").css({"background-color":"green"});},2*delay);
                
         }, 2*delay);
      }</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.round {
      
      border-radius: 50%;
   width: 20px;
   height: 20px; 
      margin: 0 auto;
      border: solid 2px #59B3AD;
      border-color:#59B3AD;
      
  } 
   .center {
     margin:0 auto;
   }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;input type="range" id="speed" min="1" max="20" step="2" onchange="metronome()" class="center"&gt;
  &lt;div id="metronome" class="round"&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>