Как задать текст span как value для input?

Как задать текст span как value для input?

<input class="input-example">
<span class="span-example">Текст</span>


Ответы (1 шт):

Автор решения: Leks

let span = document.querySelector('.span-example');
let input = document.querySelector('.input-example');

input.addEventListener('input', (e) =>{
  span.textContent = input.value;
})
<input class="input-example">
<span class="span-example">Текст</span>

→ Ссылка