title: Javascript While or If statement to run a set interval function with
body: <p>I need a javascript while look that looks for the condition ":visible" on a DOM object and only runs the code when the DOM object is actually visible.</p>
  
  <p>This is my code so far.</p>
  
  <pre><code>if (("#rightPanel").is(":visible") == true){
    // It's visible, run fetch on interval!
    setInterval(function() {
      updateChatField()
    }, 500);
  } else {
      // Do Nothing!
  };
  </code></pre>
  
  <p>What do I need to adjust to get my desired effect? Right  now I'm getting <code>("#rightPanel").is</code> is not a function.</p>