user3688491 user3688491 - 11 months ago 64
HTML Question

Bind two inputs so they display the same text even if one of them was changed using only native JS

I know how do that with Jquery But can you help me with native JS.



<input type="text" class="inputs" value="hello">
<input type="text" class="inputs" value="John">

Answer Source
const inputs = document.querySelectorAll(".inputs");
inputs.forEach(input => {
  input.addEventListener("keyup", e => {
    let value =;
    inputs.forEach(input => input.value = value);