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

98
Visualizações
CSS property changing then going back to initial value instantly

I want to change the CSS properties permanently, in this example i want to hide the text 'Hide me' and show 'Show me' instead after clicking on the 'Next' button.

function Next() {
  document.querySelector('#hideme').style.display = 'none';
  document.querySelector('#showme').style.display = 'block';
}
#hideme {
  display: block;
}

#showme {
  display: none;
}
<form>
  <input type="text" name="text">
  <input type="submit" value="Next" onclick="Next()">
</form>
<div id="hideme">Hide Me</div>
<div id="showme">Show Me</div>

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

0

The issue is to do with your code using the <form> element and an <input type="submit">. By default, a form will try and 'post' information when using a 'submit' input.

As your form has no 'action' property, it triggers and reloads the page which gives the impression that there's an issue.

Change your HTML markup and use a <button> with your JavaScript function to change page(s).

   <div>
     <input type="text" name="text">
      <button onclick="Next()">Next</button>
      <input type="submit" value="Submit">
   </div>
  
   <div id="hideme">Hide Me</div>
   <div id="showme">Show Me</div>
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