title: How to replace and append with Javascript
body: <p>I have a comment system in which I want to realize inline-editing (when someone knows a good plugin or something similar please don't hesitate to give me a name) and found a Javascript snippet which replaces the text with a textarea and the text as the value of that textarea.</p>
  
  <p>But now I need to add a button (submit button) to that textarea so that the user could save the text he edited.</p>
  
  <p>My code looks now like</p>
  
  <pre><code>&lt;span id="name"&gt;comment&lt;/span&gt;
  
  &lt;div onclick="replacetext();"&gt;test&lt;/div&gt;
  
  &lt;script type="text/javascript"&gt;
      function replacetext(){
              $("#name").replaceWith($('&lt;textarea&gt;').attr({ id: 'name', value: $('#name').text() }));
      &lt;/script&gt;
  </code></pre>
  
  <p>I've tested it out with <code>$("#name").append('&lt;button&gt;yes&lt;/button&gt;');</code> but it didn't work.</p>