Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

92
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!