Reputation: 167
I know how do that with Jquery http://jsfiddle.net/69UAT/ But can you help me with native JS. jQuery:
$('.inputs').on('keyup',function(){
$(this).parent().not(this).find('.inputs').val($(this).val());
}
);
HTML:
<div>
<input type="text" class="inputs" value="hello">
<input type="text" class="inputs" value="John">
</div>
Upvotes: 0
Views: 145
Reputation: 1480
const inputs = document.querySelectorAll(".inputs");
inputs.forEach(input => {
input.addEventListener("keyup", e => {
let value = e.target.value;
inputs.forEach(input => input.value = value);
});
});
Upvotes: 2