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

336
Visualizações
Problems with hidden div, why doesn't it work?

I have already looked at several examples here on this site but my problem still persists.

Let me explain briefly: I have a series of if / if else that must return the corresponding div to me, based on the type. And so far there are no problems.

Now I want that, in case the type is missing, it will return me a hidden div, therefore not visible

I tried as written below, but for example, if the youtube video is missing, a picture with a black border and a white background appears. I would like to eliminate this "picture" because it is not a good practice to show.

How come it doesn't work like I did?

<div class="video"> <iframe id="idframe" width="600" height="400" > </iframe> </div> <br>

else if 
.
.
.
else if (myArray.Items[2].type == "video"){
        document.getElementById("idframe").src = "https://www.youtube.com/embed/"+idurl;
    }
 else if(myArr.Items[2]type == ""){
        document.getElementById("idframe").style.display='none';
    }
.video {
    display: block;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

I think the there is an issue with this line:

document.getElementById("").style.display='none';

maybe you miss id here in getElementById("")

about 4 years ago · Juan Pablo Isaza Relatório

0

You stated that if the video is missing, a picture appears.

Have you checked that the array item returns a blank value, and not some other value?
Perhaps it would be better to have a catch all instead:

For example:

else {
document.getElementById("idframe").style.display='none';
}
about 4 years ago · Juan Pablo Isaza 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