title: Need help to get the last page from scrollTop with jquery
body: <p>I just learn about javascript and need A little bit help to get the last page element from jquery scrollTop.</p>
  
  <p>So here my code :</p>
  
  <pre><code>$(window).scroll(function() {
      $("ul.pages li").each(function(i,e){
                      var offset = $(e).offset();
          if($(window).scrollTop() &gt;= offset.top){
              $(".right_footer").text($(e).attr("data-id"));
          }   
      })
  });
  </code></pre>
  
  <p>In html code </p>
  
  <pre><code>&lt;ul class="pages"&gt;
     &lt;li class="section" data-id="page_1"&gt;&lt;/li&gt;
     &lt;li class="section" data-id="page_2"&gt;&lt;/li&gt;
     &lt;li class="section" data-id="page_3"&gt;&lt;/li&gt;
     &lt;li class="section" data-id="page_4"&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p></p>
  
  <p>Well, when I scrolling the page I got all the value from <code>data-id</code> ( <code>page_1</code>,<code>page_2</code>,<code>page_3</code>,<code>NAN</code> ), but I can not get the last value from <code>data-id="page_4"</code>, javascript said <code>NAN</code>.</p>
  
  <p>Can anybody help me??</p>
  
  <p>Thanks All!</p>