【问题标题】:How to know if images failed to load in javascript?如何知道图像是否无法在 javascript 中加载?
【发布时间】:2012-09-18 22:57:48
【问题描述】:

有什么方法可以知道有些图片在jquery/javascript的网页中加载失败。

【问题讨论】:

    标签: javascript jquery asp.net html web


    【解决方案1】:

    使用:.error()

    $('img').error(function() {
      alert('Failed to load the image with src: ' + $(this).attr('src'));
    });
    

    【讨论】:

      猜你喜欢
      • 2011-12-04
      • 1970-01-01
      • 1970-01-01
      • 2011-04-17
      • 1970-01-01
      • 1970-01-01
      • 2010-11-18
      • 1970-01-01
      • 2022-05-13
      相关资源
      最近更新 更多