案例:jQuery案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<html>
2
<head>
3
<script type="text/javascript" src="/js/jquery.js"></script>
4
<script type="text/javascript">
5
$(document).ready(function(){
6
  $("img").error(function(){
7
    $("img").replaceWith("<p><b>图片未加载!</b></p>");
8
  });
9
});
10
</script>
11
</head>
12
<body>
13
<img src="errorimg.gif" />
14
<p>如果上面的图像没有正确地加载,会被替换为一段 "图片未加载" 的文本。</p>
15
</body>
16
</html>
17