replace ids of html elements in jquery clone object
<p>So I have some HTML that I would like to be cloned several times and appended to the document. It's just typical HTML form stuff. But since things like <code>&lt;label for="something"&gt;</code> works based on element IDs, it would be nice if each HTML element within the jquery <code>clone()</code>'d element could have a unique ID, apart from all their cloned counterparts. Just as a guess to how I could do this, I wonder if it would be possible to make the IDs within my initial element all contain some unique string. I could then somehow traverse the element and replace that string with a _1,_2,_3 etc. </p>

<p>I haven't gotten very far, but it seems like something like this should work. </p>

<pre><code>$(document).ready(function(){
  var toReplace = "containerUniqueCharacterString1234";
  var copy = $('#containerUniqueCharacterString1234').clone(true);

  copy[0].style.display = "block"; //so i can reference the first element like this

  console.log(copy[0]); //[object HTMLDivElement] 

  $('body').append(copy);

  $.each(copy, function(index, value){

    var children = copy[index].childNodes;
    console.log(children); //[object NodeList] 

    var len = children.length;

    if (copy[index].childNodes.length &gt; 0){
      if (copy[index].childNodes.hasOwnProperty('id')){

        //replace the toReplace string with an incremented number here(?)
        //annnnd this is where i've gotten in too deep and made this overly complex

       }
    }

    $('#otherResults').append(len);

  });
});
</code></pre>

<p><a href="http://jsbin.com/ecojub/1/edit" rel="nofollow">http://jsbin.com/ecojub/1/edit</a></p>

<p>Or perhaps there's a much much simpler way to do this.
Thanks!</p>
