I've searched alot to find the answer, but on every page or every question the problem is either the Person didnt include the jQuery files proberly or they were naming something wrong. I tried to use different jQuery CDNs, but obviously the same error came. I even deleted my whole script to look if there is a conflict with the code. Strange thing is, only the .error() handler gets this error. Every other handler works fine. If i call .error() on an other element, it spits out the same error.
HTML:
<img class="prev_img" src="img/no_image.png" alt="Vorschau Bild" width="250px" height="160px">
JS
<script
src=".4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
crossorigin="anonymous"></script>
<script type="text/javascript">
$(document).ready(function(){
$("img").error(function(){
console.log("Error");
});
});
</script>
I really don't know what the Problem could be. I restarted my XAMPP multiple times in Hope its messing something up with the file inclution. But it seems that everything works fine.
I'm glad if i could get some help.
Greetings
EDIT:
I've tried using
$(document).ready(function(){
$("img").on("error", function(){
console.log("Error");
});
});
but even though in the console i get a GET
404 not found error, the error handler doesnt do anything.
I've searched alot to find the answer, but on every page or every question the problem is either the Person didnt include the jQuery files proberly or they were naming something wrong. I tried to use different jQuery CDNs, but obviously the same error came. I even deleted my whole script to look if there is a conflict with the code. Strange thing is, only the .error() handler gets this error. Every other handler works fine. If i call .error() on an other element, it spits out the same error.
HTML:
<img class="prev_img" src="img/no_image.png" alt="Vorschau Bild" width="250px" height="160px">
JS
<script
src="https://code.jquery./jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
crossorigin="anonymous"></script>
<script type="text/javascript">
$(document).ready(function(){
$("img").error(function(){
console.log("Error");
});
});
</script>
I really don't know what the Problem could be. I restarted my XAMPP multiple times in Hope its messing something up with the file inclution. But it seems that everything works fine.
I'm glad if i could get some help.
Greetings
EDIT:
I've tried using
$(document).ready(function(){
$("img").on("error", function(){
console.log("Error");
});
});
but even though in the console i get a GET
404 not found error, the error handler doesnt do anything.
1 Answer
Reset to default 6Per the documentation, .error()
was deprecated in 1.8 and removed in 3.0.
Use .on("error", function() { ... })
instead.
$("img").on("error", function() {
console.log("Error");
});
<script src="https://cdnjs.cloudflare./ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<img src="">
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744238776a4564602.html
评论列表(0条)