title: javascript replace url link loop
body: <p>I am a beginner for Javascript, read several post here but could not get my codes work. Hope you can explain the solution :)  </p>
  
  <p>So basically I have four set of images, but I need to replace all of the  <code>$_12.JPG</code>to <code>$_57.JPG</code> in their URL so I get bigger size of pictures (only images that are assigned to <code>class="ebay"</code> / <code>id="ebay"</code>). I need this to be executed when the browser starts reading the page, no events or buttons involved. </p>
  
  <p>The following is my source code:</p>
  
  <pre><code>&lt;div&gt;
  &lt;img class="ebay" id="ebay" u="image" src="http://i.ebayimg.com/00/s/NzgwWDc4MA==/z/neAAAOSwrklU28I8/$_12.JPG?set_id=880000500F"&gt;
  &lt;img u="thumb" src="http://i.ebayimg.com/00/s/NzgwWDc4MA==/z/neAAAOSwrklU28I8/$_12.JPG?set_id=880000500F"&gt;
  &lt;/div&gt;
  &lt;div&gt;
  &lt;img class="ebay" id="ebay" u="image" src="http://i.ebayimg.com/00/s/NzgwWDc4MA==/z/r8cAAOSwNSxU28I9/$_12.JPG?set_id=880000500F"&gt;
  &lt;img u="thumb" src="http://i.ebayimg.com/00/s/NzgwWDc4MA==/z/r8cAAOSwNSxU28I9/$_12.JPG?set_id=880000500F"&gt;
  &lt;/div&gt;
  &lt;div&gt;
  &lt;img class="ebay" id="ebay" u="image" src="http://i.ebayimg.com/00/s/NzgwWDc4MA==/z/HLgAAOSwPhdU28I-/$_12.JPG?set_id=880000500F"&gt;
  &lt;img u="thumb" src="http://i.ebayimg.com/00/s/NzgwWDc4MA==/z/HLgAAOSwPhdU28I-/$_12.JPG?set_id=880000500F"&gt;
  &lt;/div&gt;
  &lt;div&gt;
  &lt;img class="ebay" id="ebay" u="image" src="http://i.ebayimg.com/00/s/NzgwWDc4MA==/z/6VkAAOSwPYZU28I-/$_12.JPG?set_id=880000500F"&gt;
  &lt;img u="thumb" src="http://i.ebayimg.com/00/s/NzgwWDc4MA==/z/6VkAAOSwPYZU28I-/$_12.JPG?set_id=880000500F"&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I also like to loop the function so when I have more than 4 sets of pictures (maximum 15 sets) and the javascript can still replace the URL for me. </p>
  
  <p>The following is what I had tried:</p>
  
  <pre><code>window.onload = function() {
  
      for ( var i = 0; i &lt; currentLink.length; i++) {
  
      var currentLink=document.getElementByClassName('ebay');
      var newLink = currentLink.src.replace('$_12.JPG','$_57.JPG');
      currentLink.src = newLink;
  
      }
  }
  </code></pre>