title: jQuery: Giving each matched element an unique ID
body: <p>I am writing an 'inline translator' application to be used with a cloud computing platform to extend non-supported languages. The majority of this uses jQuery to find the text value, replace it with the translation, then append the element with a span tag that has an unique ID, to be used elsewhere within the application.  The problem arises however, when there are more than one element, say , that have the exact same value to be translated (matched elements).  What happens in the function in question is that it puts all matched elements in the same span, taking the second, third, fourth, etc. out of their parent tags.  My code is pretty much like this example:</p>
  
  <pre><code>&lt;script src='jquery-1.4.2.js'&gt;&lt;/script&gt;
  &lt;script&gt;
  jQuery.noConflict();
  var uniqueID='asdfjkl';
  jQuery(window).ready(function() {
  var myQ1 = jQuery("input[id~=test1]");
  myClone=myQ1.clone();
  myClone.val('Replaced this button');
  myQ1.replaceWith('&lt;span id='+uniqueID+'&gt;&lt;/span&gt;');
  jQuery('#'+uniqueID).append(myClone);
  });
  &lt;/script&gt;
  &lt;table&gt;
  &lt;tr&gt;&lt;td&gt;
  &lt;input id='test1' type='button' value="I'm a button!"&gt;&lt;/input&gt; &amp;nbsp;
  &lt;input id='test2' type='button' value="And so am I"&gt;&lt;/input&gt;
  &lt;/tr&gt;&lt;/td&gt;
  &lt;tr&gt;&lt;td&gt;
  &lt;input id='test1' type='button' value="I'm a button!"&gt;&lt;/input&gt;
  &lt;/tr&gt;&lt;/td&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>As a workaround, I've experimented with using a loop to create a class for each span, rising in increment until jQuery("input[id~=test1]").length, but I can't seem to get anything I do to work.  Is there any way to give each matched element an unique ID?  My fluency in jQuery is being put to the test! </p>
  
  <p>Thanks for any help in advance.</p>
  
  <p>Aaron</p>