title: insert jquery variable into html input
body: <p>Aim is to get value from one input cell and insert to another.</p>
  
  <p>To get value I use </p>
  
  <pre><code>var name = $('#test').val();
  </code></pre>
  
  <p>And the above works.</p>
  
  <p>Then I need to insert. If I insert simple text (not variable), then it works</p>
  
  <pre><code>$("#test3").val("Dolly Duck");
  </code></pre>
  
  <p><strong>But how to insert variable (var name) instead of val("Dolly Duck")?</strong></p>
  
  <p>Below if whole code</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"&gt;&lt;/script&gt;
  
  &lt;script type="text/javascript"&gt;
  
  //This works
  $("#btn3").click(function(){
  $("#test3").val("Dolly Duck");
  });
  
  //But his does not work
  //at first get value from input form (define variable) and alert to check if it works
  var name = $('#test').val();
  //alert(name);
  
  //now need to insert
  //$("#btn4").click(function(){
  
  //below does not work None of them
  //$("#test").name;
  //$("#test4").$('#test').val();
  //$("#test4").jsvar: $('#test').val();
  
  });
  });
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;p&gt;Name: &lt;input type="text" id="test" value="Mickey Mouse1"&gt;&lt;/p&gt;
  &lt;p&gt;Name: &lt;input type="text" id="test3" value="Mickey Mouse2"&gt;&lt;/p&gt;
  &lt;p&gt;Name: &lt;input type="text" id="test4" value="Mickey Mouse3"&gt;&lt;/p&gt;
  &lt;button id="btn1"&gt;Show Value&lt;/button&gt;
  &lt;button id="btn3"&gt;Set Value&lt;/button&gt;
  &lt;button id="btn4"&gt;Set Value&lt;/button&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>