I am trying to set the value of an existing input filed to another input filed with onclick.
<p>Name: <input id="john" type="text" value="" name="user"></p>
<input type="hidden" value="John" />
<span>Set value</span>
When click on span, the value of the hidden input
(in this case John
) should be placed as value ont the input field above it. So onclick:
<p>Name: <input id="john" type="text" value="" name="user"></p>
becomes
<p>Name: <input id="john" type="text" value="John" name="user"></p>
How can i do that with jquery?
I already have this code but i do not succeed in it:
$("span").click(function(){
$("input:#john").val();
});