title: How to set the dynamic ids for link?
body: <p>I have a horizontal menu. I want to create an id for each using jQuery. My code is:</p>
  
  <pre><code>&lt;div class="menuBar"&gt;
      &lt;div class="menuHeader ui-corner-top"&gt;
          &lt;span&gt;&lt;a href="#" onclick="Home()"&gt;Home&lt;/a&gt;&lt;/span&gt;
      &lt;/div&gt;
      &lt;div class="menuHeader ui-corner-top"&gt;
          &lt;span&gt;&lt;a href="#" onclick="NewTransaction()" id="menu2"&gt;New Transaction&lt;/a&gt;&lt;/span&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Here menu has no id. I want to create id dynamically using jQuery. How can I do this? I did an example like this, but it is not working:</p>
  
  <pre><code>var i = 0;
  $('.menuHeader').each(function () {
      i++;
      newID = menu + i;
      $(this).attr('id', newID);
      $(this).val(i);
  });
  </code></pre>