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

245
Views
Javascript DIV Not Displaying After Changing CSS

I have a DIV for spinner:

<div id="spinner" style="display:none;z-index:100;position:absolute;top:50%;left:50%;margin-top:-50px; margin-left:-50px;">
     <img src="..\spinner.gif" alt="Loading" />
</div>

The code document.getElementById("spinner").style.display = "block" changes the style of the spinner to block but the spinner div not showing:

document.getElementById("spinner").style.display = "block";

getAllStudents(); //this function gets data from MySQL tables and populate a table on the page

document.getElementById("spinner").style.display = "none";
about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Instead of adding display: none; after the function call, try adding the code just before you start populating the table on page.

document.getElementById("spinner").style.display = "none";
about 4 years ago · Santiago Trujillo Report

0

Two Ideas:

  1. If the image src is incorrect, I've sometimes found it doesn't display anything, even with an alt = "Loading" tag. You might want to test the link it's displaying the image from to verify it works. (Don't just test the src link).
  2. Assuming the image src is correct, you could remove the image from <div id="spinner"/> and add it separately as <img id="spinner" src="..\spinner.gif" alt="Loading" /> and then you could have your <div show what you want.

EDIT: (3 ideas now)

  1. Change your src attribute so all of the \ characters are replaced with /. I tried an image in my own script with src = "..\spinner.png" and it wouldn't even run, but doing src = "../spinner.png" did. Hopefully this solves your problem.
about 4 years ago · Santiago Trujillo 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!