title: JQuery Replace String In Attribute
body: <p>I am trying to change the string within an <code>attr('src')</code> in just the beginning of the address, and after the replacement, it keeps the latter information.
  Here's the html:</p>
  
  <pre><code>&lt;img src="../folder1/folder2/folder3/picture.png" /&gt;
  
  &lt;img src="../folder1/folder2/folder3/picture2.png" /&gt;
  </code></pre>
  
  <p>It would need to perform this after pageload, here's my existing script/scripts:</p>
  
  <pre><code>$(document).ready(function(e) {
      // this is one attempt
      $('img').each(function() {
          var src = $(this).attr('src');
          $(this).ready(function() {
              $(this).attr('src', src.replace('../', '/'));
          }, function() {
              $(this).attr('src', src);
          });
      });
  
      // this is another attempt, not both used at the same time
      $('img').attr('src').replace('../', '/');
  
      // I also tried this
      $('img').each(function() {
          if($(this).attr('src') == '../') {
              $(this).attr('src', '/');
          };
      });
  });
  </code></pre>
  
  <p>The overall goal is to produce this result:</p>
  
  <pre><code>&lt;img src="/folder1/folder2/folder3/picture.png" /&gt;
  
  &lt;img src="/folder1/folder2/folder3/picture2.png" /&gt;
  </code></pre>