Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

335
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda