Jquery: Not returning position values
<p>I have the following code  in <a href="http://jsfiddle.net/dev1212/WdJKS/" rel="nofollow">JSFIDDLE DEMO</a> and I am trying to get the position value of </p>

<p><code>&lt;a name="link1"&gt;&lt;/a&gt; ,  &lt;a name="link2"&gt;&lt;/a&gt; , &lt;a name="link3"&gt;&lt;/a&gt;</code> and so forth on the page.</p>

<p>When i try to get the pos it does nothing.
Using this , it doesnt return the position and also prevent its from scrolling</p>

<pre><code> var pos = $("[name='" + $(this).attr('href').replace("#", '') + "']").position();
</code></pre>

<p>How can i get position for each of these <code>&lt;a name="link1"&gt;</code> and so forth so i can pass the position value to scroll to in the page?</p>

<p>JQUERY</p>

<pre><code> $(document).ready(function () {


        //  $("ul" + anchorLinksId + " li a").click(function (e) {
        $("ul#mainNav li a").click(function (e) {
            e.preventDefault();

            var pos = $("[name='" + $(this).attr('href').replace("#", '') + "']").position();
            //var pos = $(this).attr("href").replace("#", '') + "']").position();
            alert("left = " + pos.left + ", top = " + pos.top);
            var hrefval = $(this).attr("href");

            if (hrefval == "#license") {
                $('html, body').animate({
                    scrollTop: pos + 5
                }, 600);
            } else if (hrefval == "#link2") {
                $('html, body').animate({
                    scrollTop: pos + 5
                }, 600);
            } else if (hrefval == "#link3") {
                $('html, body').animate({
                    scrollTop: pos + 10
                }, 600);
            } else if (hrefval == "#link4") {
                $('html, body').animate({
                    scrollTop: pos + 10
                }, 600);
            } else if (hrefval == "#link5") {
                $('html, body').animate({
                    scrollTop: pos + 10
                }, 600);
            } else if (hrefval == "#link6") {
                $('html, body').animate({
                    scrollTop: 4039
                }, 600);
            } else {}


        });


    });
</code></pre>
