title: JS clearInterval() will not clear
body: <p>Just moments ago I asked a question about why my setInterval() function would only run once,</p>
  
  <p><a href="https://stackoverflow.com/questions/19371647/js-setinterval-only-runs-once-when-animating-opacity">JS setInterval() only runs once when animating opacity</a></p>
  
  <p>I had that answered, but then I wanted to check and make sure the loop stopped, so I added an alert() to the loop and found out clearInterval is not clearing even though I initially ran the setInterval function connected to a global variable... </p>
  
  <p>the opacity change works fine, but now the alert box goes on infinitely after you click OK... eventually I won't need the alert function I just wanted to see if the interval actually cleared which it doesn't...</p>
  
  <pre><code>var run;
  var runOpt;
  
  document.getElementById('menu-1-A').style.opacity=0;
  document.getElementById('menu-1-B').style.opacity=0;
  
  function openSubMenu1(item) {
      runOpt=item;
      run = setInterval(runSubMenu1,35);
  }
  
  function runSubMenu1()  {
  
      var i=document.getElementById('menu-1-'+runOpt);
  
      if (parseInt(i.style.opacity) == 1) {
        clearInterval(run);
        alert('done');
  
      } else {
        i.style.opacity = parseFloat(i.style.opacity) + .1;
      }
  }
  </code></pre>