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

246
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 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