title: Set new id with jQuery
body: <p>"this" is a text field, "new_id" is an integer.</p>
  
  <p>When I apply the following snippet:</p>
  
  <pre><code>$(this).attr('id',   this.id + '_' + new_id);
  $(this).attr('name', this.name + '_' + new_id);
  $(this).attr('value', 'test');
  </code></pre>
  
  <p>the id changes, the name changes too, but not the value. If I change the last line to this (and therefore use a string literal)</p>
  
  <pre><code>$('#mytextfield_3').attr('value', 'test');
  </code></pre>
  
  <p>it works.</p>
  
  <p>Any ideas?</p>
  
  <p>-- EDIT --
  Thanks to Steerpike for the quick plugin test - i believe it should work, but i can't find the error.</p>
  
  <p>Here's some more code:</p>
  
  <p>I create the clone using</p>
  
  <pre><code>clone = $(this).find('.clone_fields_container:first').clone();
  </code></pre>
  
  <p>"clone" now contains a div which has embedded input fields.</p>
  
  <p>After generating a new id:</p>
  
  <pre><code>  /** Iterate over input and select fields in container */
  
    clone.children('input,select,textarea').each(function() {
      $(this).attr('id',   this.id + '_' + new_id);
      $(this).attr('name', this.name + '_' + new_id);
      $(this).val('test');
      console.log(this);
    });
  </code></pre>
  
  <p>The text fields do not have any values.</p>