title: looping through form items using JQuery's .each and changing the src with .replace
body: <p>I know how to do this using good old JavaScript but I want to reduce my code and get a better understanding of jQuery, so here' my problem:</p>
  
  <p>I have a collection of images and inputs that all contain a SRC attribute, these are all contained within a parent DIV called #popupForm. I wish to use the .each method to loop through my form items (some are in child DIVs for styling) and replace part of the SRC depending on a match in the string - I won't go into why I want to do this but I have a site that has numerous themes. Here's what I have so far</p>
  
  <pre><code>var thisTheme = $("hiddenTheme").val(); // this is a theme variable
  var $inputs = $('#popupForm :input');  // need to later add images here too
  
  $inputs.children().each(function () {
  $this.attr("src") = $this.attr("src").replace('whatIwantToReplace', thisTheme);
  });
  </code></pre>
  
  <p>This should be fairly simple. Any help is appreciated.</p>
  
  <hr>
  
  <p>Update</p>
  
  <hr>
  
  <p>Got this to work with the following</p>
  
  <pre><code>// theming script
  var thisTheme = $("#hiddenTheme").val();
  var defaultTheme = "/midway/"
  
  $('#popupForm img').each(function () {
  
      var thisSRC = $(this).attr('src');
      if (thisSRC.indexOf(defaultTheme) !== -1) {
  
          var new_src = $(this).attr('src').replace(defaultTheme, thisTheme);
          $(this).attr('src', new_src);
  
      }
  
  });
  </code></pre>