<!DOCTYPE html>
<html>
<head> <meta charset="UTF-8"> <title>Insert title here</title> <script src="http://cdn.bootcss.com/jquery/2.1.0-beta3/jquery.min.js"></script> </head> <body> <img id="img" src="clock60.png" retry="0" > <script> $(function() { $('#img').on('error', function() { var retry= $('#img').attr("retry"); if (retry > 0) { $('#img').attr('src', 'https://iustudio.science/images/srpr/logo11w.png'); } else { retry++; $('#img').attr("retry", retry); $('#img').attr('src', $('#img').attr('src')); } }); }) </script> </body> </html>
转载于:https://www.cnblogs.com/wangjiaojiao/p/4585739.html