Write a jQuery code to fix broken images automatically.
Answer :
File Name : jQuery5.html
<html>
<head>
<script src="https://code.jquery.com/jquery-3.6.0.js" integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk=" crossorigin="anonymous"></script>
<title>SP Creation</title>
</head>
<body>
<img src="include/img/logo.png" width="64" height="64" />
<img src="hhttp://www.google.com/linktoa404page" width="64" height="64" />
<img src="include/img/logo.png" width="64" height="64" />
<script>
$('img').bind('error', function(e) {
$(this).attr('src', 'include/img/logo.png');
});
</script>
</body>
</html>
Write a jQuery code to fix broken images automatically.
Reviewed by technical_saurabh
on
April 30, 2021
Rating:
No comments:
Post a Comment