实例代码“Ctrl+/”提示“F11/ESC”全屏 返回 格式化 恢复 运行
x
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<script src="https://libs.baidu.com/jquery/1.10.2/jquery.min.js">
5
</script>
6
<script>
7
$(document).ready(function(){
8
  $("img").error(function(){
9
    $("img").replaceWith("<p>Error loading image!</p>");
10
  });
11
  $("button").click(function(){
12
    $("img").error();
13
  });
14
});
15
</script>
16
</head>
17
<body>
18
19
<img src="img_pulpitrock.jpg" alt="Pulpit rock" width="284" height="213">
20
<br>
21
<button>Trigger error event for the image</button>
22
23
</body>
24
</html>