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

190
Visualizações
Get value from input several times without refreshing the page

I have an input and a button. When I clicked the button I want to take the value from input and put it into a variable. How can do this action several times without refreshing the page ? Example: Input: John Button: click let x = John -->without refreshing the page Input: Bob Button: click let x = Bob

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You need a variable to store the value of the input and a function that is being called when the button is clicked. name in this example holds the value of the input and is updated everytime the button is clicked.

let name;
document.querySelector("#btn").addEventListener("click", () => {
  name = document.querySelector("#name").value;
  console.log(name);
});
<input id="name" />
<button id="btn">Click me</button>

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