how to find the vertical distance from top in px of an element using jQuery
<p>How do I find the vertical distance from the top of the page to where the element exist in the DOM using javascript/jQuery?</p>

<p>I've something like</p>

<pre><code>&lt;ul&gt;
    &lt;li&gt;one&lt;/li&gt;
    &lt;li&gt;one&lt;/li&gt;
    &lt;li&gt;one&lt;/li&gt;
    &lt;li&gt;one&lt;/li&gt;
    &lt;li class="test"&gt;one&lt;/li&gt;
    ....
    ....
    ....
    &lt;li&gt;one&lt;/li&gt;
&lt;/ul&gt;
</code></pre>

<p>For example here, I want to find the vertical distance from top of the page to the <code>li#test</code> element.</p>

<p>I tried <code>.scrollTop()</code> but it always comes as 0!</p>
