how do I iterate over the results of a jquery selector
<p>When I'm trying to store all <code>&lt;a&gt;</code> elements as objects in array (using <code>$('a')</code>), and then get the position of each of them, it doesn't work. </p>

<pre><code>years = $('a');
for(i=0;i&lt; years.length;i++){
   if(years[i].position().top &gt; year.position().top){

   }
   else{

   }
}
</code></pre>

<p>Console says:</p>

<blockquote>
  <p>Uncaught TypeError: Object file:///Users/.../index.html# has no method 'position'</p>
</blockquote>

<p>When I do it with single element selected by class name instead of tag name, everything works fine.</p>

<p>What am I doing wrong ?</p>
