title: How to dynamically add attributes to mulitple div with same class name using jquery?
body: <p>I have a "div" written in my html code like this</p>
  
  <pre><code>&lt;div class="mydata"&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>and this is created dynamically when page renders so how many div with this same class name is going to be created is not fixed but using my code i can get the total no of div presented at a time after page load.</p>
  
  <p>i stored that value in a variable "counter".</p>
  
  <p>so for example at some time if their are 5 div with "mydata" class name then counter have 5 value</p>
  
  <p>but now i want to add id attribute(Start from 1 upto counter value)   to each div.</p>
  
  <p>ex: first div is look like this <code>&lt;div class="mydata" id="1"&gt;&lt;/div&gt;</code></p>
  
  <p>second one is like this <code>&lt;div class="mydata" id="2"&gt;&lt;/div&gt; and so on.</code></p>
  
  <p>so please tell me how can add this id attr to my div(as discribed other )using jquery ?</p>
  
  <p>-Thanks </p>