All health and happiness! A written script that should iterate through all the pictures, if the pictures did not load, then the script should hide the parent block under the .Parent_block class, that is, I have 3 blocks, there is a picture in the central block, but not in the other two, which means they should have property display:none
But I did something wrong. Where did I make a mistake?
let parent_block = document.querySelectorAll('.Parent_block');
let image_b = document.querySelectorAll('.Child_Img');
image_b.forEach(function(){
if(image_b.onerror){
for(let parent_block of hide){
hide.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"> <!-- ***** this block should disappear ***** =( -->
<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"> <!-- ***** and this one too ***** =( -->
<img class="Child_Img" src="">
<figcaption class ="Img_text">3</figcaption>
</figure>