title: How do I change the value of an input box in a variable using jquery?
body: <p>I have a variable containing a form with an input box, and I'd like to change the value attribute of said input box using jquery. So far, I'm able to change the value, but it doesn't get changed in the outer html. This' what I've got so far:</p>
  
  <pre><code>$("a").click(function(event) {
      var form_content = "&lt;form&gt;&lt;input id=\"name\" value=\"Test value\"/&gt;&lt;/form&gt;";
      var test = $('&lt;div /&gt;').html(form_content).find('#name').val('New test value').parent();
      alert(test.find('#name').val());
      alert(test.html());
      return false;
  });
  </code></pre>
  
  <p>also available at <a href="http://jsfiddle.net/tndn7/" rel="nofollow noreferrer">jsfiddle</a>. The first <code>alert</code> displays <code>"New test value"</code>, yet the second <code>alert</code> doesn't reveal any hint of how this new value is stored - basically it returns the same value as the original variable <code>form_content</code>. </p>
  
  <p>I've had a look <a href="https://stackoverflow.com/a/2352080/182048">here</a>, but can't understand what I'm doing wrong.</p>
  
  <p>Could anyone please help me connect the dots, and possibly give me a hint of how I can change the html stored in <code>form_content</code>? (There seems to be plenty of examples of how to do it in plain static html, but that's unfortunately not an option for me.) Thanks!</p>