I am trying to hide the container of an image when it can't be fournd. So far this workes which hide the "image not found" icon:
document.addEventListener("DOMContentLoaded", function(event) {
document.querySelectorAll('img').forEach(function(img){
img.onerror = function(){
this.style.display='none';
};
})
});
But when I change this line:
this.display='none';
to
this.parent().display='none';
it's not working. How can I hide the container image?
This isn't jQuery, just good ol' DOM.