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

102
Views
Change display of element after while loop

I want to show a loading screen until a while loop completes. Here is some code to briefly illustrate the principle behind my problem. I need to be using a while loop for the logic I have. The while loop's execution time will significantly vary based on user input.

var x = 0;
var y = 100;
document.getElementById("x").style.display = "block";
while (x < y) {
x++;
}
document.getElementById("x").style.display = "none";
console.log("done");

The issue is in updating the DOM after execution. Console logs fine, but the element's style doesn't change so that it disappears.

about 4 years ago · Santiago Gelvez
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!