How to fix broken images automatically Using jQuery?

Hello friends, today I will tell you through experts tool tutorial How to Fix Broken Images Automatically Using JQuery? So let’s try to understand step to step with example.

jQuery hide() Method: This method is used to hide the element corresponding to the specific selector.

Syntax:

$(selector).hide(duration, easing, callFunc);

Parameter: It accepts three parameters which are specified below:

duration: Set the speed of the hide effect.

easing: Set the speed of the element at a different point.

callFunc: A call back function to be executed after the hide operation.

index.html

<!DOCTYPE html>
<html>
<title>How To Fix Broken Images Automatically Using JQuery?</title>
<head>
<!-- jQuery -->
<script src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js">
</script>
</head>
<body>
<h1>How To Fix Broken Images Automatically Using JQuery?</h1>
<!-- Broken image -->
<img src="https://www.expertsphp.com/tutorialimages/images/p.png" />
<img src="https://www.expertsphp.com/tutorialimages/images/python.png"
alt="Experts Tool" />
<img src="https://www.expertsphp.com/tutorialimages/images/python.png"
alt="Experts Tool" />
<script type="text/javascript">
$("img").bind("error", function (e) {
$(this).hide();
});
</script>
</body>
</html>