title: Can clearInterval() be called inside setInterval()?
body: <pre><code>bigloop=setInterval(function () {
                var checked = $('#status_table tr [id^="monitor_"]:checked');
                  if (checked.index()===-1 ||checked.length===0 || ){
                      bigloop=clearInterval(bigloop);
                      $('#monitor').button('enable');
                  }else{
  
                          (function loop(i) {                           
                              //monitor element at index i
                              monitoring($(checked[i]).parents('tr'));
                              //delay of 3 seconds
                              setTimeout(function () {
                                  //when incremented i is less than the number of rows, call loop for next index
                                  if (++i &lt; checked.length) loop(i);
                              }, 3000);
                          }(0)); //start with 0
                  }                            
              }, index*3000); //loop period
  </code></pre>
  
  <p>I have the code above and sometimes it is working, sometimes it is not. I am wondering <strong>if the clearInterval actually clear the timer??</strong> because there is this <code>monitor</code> button that will only be disabled when it is in <code>monitoring</code> function. I have another <code>clearInterval</code> when an element called <code>.outputRemove</code> is clicked. See the code below:</p>
  
  <pre><code>//remove row entry in the table      
          $('#status_table').on('click', '.outputRemove', function () {
              deleted= true;
              bigloop= window.clearInterval(bigloop);
              var thistr=$(this).closest('tr');
              thistr.remove();
              $('#monitor').button('enable');
  
              $('#status_table tbody tr').find('td:first').text(function(index){
                 return ++index;
  
              });
          });
  </code></pre>
  
  <p>But it was enabled for a while before it is disabled again. <strong>Will <code>clearInterval</code> get the program out from the <code>setInterval</code> function?</strong></p>