Skip to content Skip to sidebar Skip to footer

Js Hiding Broken Images Within Class

I understand how to hide images if they're as followed, However, I'm having problems as I know nothing about JS on how to hide broken images if they're li

Solution 1:

Not trivial

Try

$(function() {
  $("[data-bg]").each(function() {
    const $parent = $(this).closest(".lx-g3-f")
    const img = newImage();
    img.onerror=function() {
      $parent.hide();
    }
    img.src=$(this).data("bg")
  })
})

Post a Comment for "Js Hiding Broken Images Within Class"