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

120
Visualizações
I don't understand why this script doesn't work in Firefox
  • This script hides the parent block
  • if it doesn't have the src of the image loaded.
  • Works in all browsers except Firefox

Is this a Firefox bug or a script issue? If the problem is in the script, how can I make it work in Firefox?

P.S. This error is not visible on this site. Try creating an index.html file locally(without using the internet) on your PC and paste this code there, then view the result in Firefox.

let images = document.querySelectorAll('.Parent_block > .Child_Img');

images.forEach(function(e) {
  e.onerror = function() {
    e.closest('.Parent_block').style.display = 'none';
  };
});
.Parent_block {
  width: 30%;
  margin: 0;
  padding: 0;
  margin-left: 10px;
  margin-top: 10px;
  border: 1px solid black;
  display: inline-block;
  height: 250px;
}

img {
  height: inherit;
  width: 100%;
}
<figure class="Parent_block">
  <img class="Child_Img" src="">
  <figcaption class="Img_text">1</figcaption>
</figure>


<figure class="Parent_block">
  <img class="Child_Img" src="https://i.ibb.co/kyXhZmB/photo-2021-11-18-14-40-18.jpg">
  <figcaption class="Img_text">2</figcaption>
</figure>


<figure class="Parent_block">
  <img class="Child_Img" src="">
  <figcaption class="Img_text">3</figcaption>
</figure>

about 4 years ago · Juan Pablo Isaza
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