Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

129
Visualizações
I could not perform the output of the value written to the input at the bottom

I want to see the input in a project and get the output at the same time. They did this only in the so-called way. But I want the output of my buttonless post. how to do?

<input type="text" id="myText">
<button type="button" onclick="myFunction()">Try it</button>
<p id="demo"></p>

  
<script>
  
// Here the value is stored in new variable x 
function myFunction() {
    var x = document.getElementById("myText").value;
    document.getElementById("demo").innerHTML = x;
}
</script>
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You can achieve your goal by using input_event on the input tag, like this:

let demo = document.getElementById('demo');
document.getElementById('myText').addEventListener('input',function(){
  demo.innerHTML= this.value;
})
#demo{ 
  background: #eee;
  min-height:20px;
}
<input type="text" id="myText">
<p id="demo"></p>

about 4 years ago · Juan Pablo Isaza Relatório

0

You should try to add an EventListener so every time the input changes the function will run.

Just add the following, I think it will work fine.

document.addEventListener('keydown', myFunction);

So on every key pressed the x variable will be assigned the current input.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda