title: How can I dynamically assign IDs to elements of a particular class using Jquery?
body: <p>I've looked at other questions, but none of them have really helped me.  I want to give IDs to a number of elements belonging to the same class without manually doing it.  Here is my code that isn't working:</p>
  
  <pre><code>$curelem = $(".item:first");
  
  for (var $i=0; i &lt; $(".item").length; ++$i){
      $curelem.attr("id", "item" + $i);
      $curelem = $curelem.next('a');
  }
  </code></pre>
  
  <p>Is it some small syntax error, or am I going about it entirely wrong?</p>