0

I am using flickity gallery and the images loaded but when I run the following the img is not removed:

$('.carousel').imagesLoaded().progress( function( instance ) {
     $('img').on("error", function () {
        $(this).remove();
    });
});

I have also tried without to run the .remove() within the gallery plugin but i still get the broken images

  $(document).ready(function() {
     $('img').on("error", function () {
        $(this).remove();
    });
  });
rob.m
  • 9,843
  • 19
  • 73
  • 162
  • is `this` pointing to a non-null element? or is the `error` event is firing exactly? please also take note that you should be attaching the event handle first before loading the image or assigning a value on the src attribute of the img tag – Roljhon Mar 26 '17 at 15:08
  • I am trying to target any image with an error or src="undefined", is it not .progress an event handler? Also should it now work if i set document ready too? – rob.m Mar 26 '17 at 15:13
  • Looking at your code, you're trying to load the image at the same time attached the event handler, you should be attaching the handler first before loading the image URL, since `error` event handler will verify the HTTP codes during runtime. You can set a second argument image on your `progress` function, and check `image.isLoaded` it returns true or false. – Roljhon Mar 26 '17 at 15:21

0 Answers0