title: Wait until div is not visible to process next line
body: <p>I need to write some code which is supposed to wait until a predefined <code>div</code> is no longer visible in order to process the next line. I plan on using <code>jQuery( ":visible" )</code> for this, and was thinking I could have some type of <code>while</code> loop. Does anyone have a good suggestion on how to accomplish this task?</p>
  
  <pre><code>$( document ).ready(function() {
      $(".scroller-right" ).mouseup(function( event ) {
          alert('right');
          pollVisibility();
      });
  });
  
  function pollVisibility() {
       if ($(".mstrWaitBox").attr("visibility")!== 'undefined') || $(".mstrWaitBox").attr("visibility") !== false) { 
              alert('inside else');
              microstrategy.getViewerBone().commands.exec('refresh');       
       } else {
                setTimeout(pollVisibility, 100);
       }
  }
  
  $( document ).ready(function() {
      $(".scroller-right" ).mouseup(function( event ) {
          alert('right');
          pollVisibility();
      });
  });
  
  function pollVisibility() {
       if (!$(".mstrWaitBox").is(":visible")) {
          alert('inside if');
          microstrategy.getViewerBone().commands.exec('refresh');     
      } else {
          setTimeout(pollVisibility, 100);
      }
  }
  </code></pre>
  
  <p><code>div</code> when not visible:</p>
  
  <pre><code>&lt;div class=​"mstrWaitBox" id=​"divWaitBox" scriptclass=​"mstrDialogImpl" dg=​"1" ty=​"edt"&gt;​
  &lt;/div&gt;​
  </code></pre>
  
  <p><code>div</code> when visible:</p>
  
  <pre><code>&lt;div class=​"mstrWaitBox" id=​"divWaitBox" scriptclass=​"mstrDialogImpl" dg=​"1" ty=​"edt" visibility="visible"&gt;​
  &lt;/div&gt;​
  </code></pre>