fmpq.com
源代码:
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Fmpq教程(fmpq.com)</title> <script src="https://apps.bdimg.com/libs/jquery/1.7.0/jquery.min.js"> </script> <script> $(document).ready(function(){ $("img").error(function(){ $("img").replaceWith("<p>图片加载错误!</p>"); }); $("button").click(function(){ $("img").error(); }); }); </script> </head> <body> <img src="img_pulpitrock.jpg" alt="Pulpit rock" width="284" height="213"> <br> <button>图片触发 error 事件</button> </body> </html>
运行结果