Stop loading of images with javascript (lazyload)?

前端 未结 9 2400
醉梦人生
醉梦人生 2020-12-19 08:03

I am trying to stop the loading of images with javascript on dom ready and then init the loading whenever i want, a so called lazy loading of images. Something like this:

9条回答
  •  误落风尘
    2020-12-19 08:58

    I had the same problem when putting the image load on the hover event on my thumbnail image, in IE it causes a "Stack Overflow" when I hover on the thumbnail image.
    But it is solved now. This code saved my day:

    $(document).ready(function() {
      var images = $('img');
      $.each(images, function() {
        $(this).removeAttr("src");
      });
    });
    

提交回复
热议问题