x
 
<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("img").error(function(){
    $("img").replaceWith("<p><b>图片未加载!</b></p>");
  });
  $("button").click(function(){
    $("img").error();
  });
});
</script>
</head>
<body>
<img src="/i/eg_tulip.jpg" />
<p>如果上面的图像没有正确地加载,会被替换为一段 "图片未加载" 的文本。</p>
<button>触发图像的 error 事件</button>
</body>
</html>