title: jquery attr add id to existing element
body: <p>I have a bunch of imgs inside a div with a class on them, in my JS I have a for loop that re-sizes the images to fir inside a box without stretching </p>
  
  <pre><code>$('.gallery img')[i].attr('id', 'img' + i);
  </code></pre>
  
  <p>This is what I tried to get each img to have its own id like 'img1' 'img2' 'img3' etc</p>
  
  <p>but it seems to not work</p>