Copy value from one input to another

2

I'm needing that when I put any value inside input1, that value already appears in input2. Since both are on the same page, can you do that?

    
asked by anonymous 31.08.2016 / 21:40

1 answer

3

You can do with jQuery by capturing the keyup event.

Run the code below and see below an example working:

   
// JavaScript (usando jQuery).

$('#input1').keyup(function(){
    $('#input2').val($(this).val());
});
 <!-- HTML -->

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><inputid="input1"/>
<input id="input2"/>
    
31.08.2016 / 21:45