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

131
Views
Hide clicked button after toggle

I'm using this code to toggle the visibility of a section. When the button is clicked, the section shows.

function myFunction() {
  var x = document.getElementById("offerte-toggle");
  if (x.style.display === "block") {
    x.style.display = "none";
  } else {
    x.style.display = "block";
  }
}
<a onclick="myFunction()" id="knop-doorz" class="witte-randen">Offerte opvragen</a>

How can I hide the button after it has been clicked?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

your JS code is targetting an element with id offerte-toggle but in your html, the has an id of knop-doorz

Either edit the html id to match the JS or vice versa.

You also don't need to do the if check, just simply set x.style.display = 'none'; before the closing } tag.

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!