title: Check if element is visible on screen
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/487073/jquery-check-if-element-is-visible-after-scroling">jQuery - Check if element is visible after scroling</a>  </p>
  </blockquote>
  
  
  
  <p>I'm trying to determine if an element is visible on screen. In order to to this, I'm trying to find the element's vertical position using offsetTop, but the value returned is not correct. In this case, the element is not visible unless you scroll down. But despite of this, offsetTop returns a value of 618 when my screen height is 703, so according to offsetTop the element should be visible.</p>
  
  <p>The code I'm using looks like this:</p>
  
  <pre><code>function posY(obj)
  {
    var curtop = 0;
  
    if( obj.offsetParent )
    {
      while(1)
      {
        curtop += obj.offsetTop;
  
        if( !obj.offsetParent )
        {
          break;
        }
  
        obj = obj.offsetParent;
      }
    } else if( obj.y )
      {
       curtop += obj.y;
      }
  
    return curtop;
  }
  </code></pre>
  
  <p>Thank you in advance!</p>