I want to replace the value (text) of “input2” by the value of “input1” when I check the checkbox
here my code:
$("#check").click(function () {
$('#input2').html($('#input1').val());
});
<input type="text" id="input2">
<input type="checkbox" id="check">
<input type="text" id="input1">
For the moment, it’s only working if “input2” is a div and not an input.
Thanks !
Use
.val()to set the value of an input not.html()