简体   繁体   English

jQuery事件.error在IE8中不起作用

[英]jquery event .error doesn't work in IE8

I try to catch event orerror in image.I have code 我尝试捕获图像中的事件或错误。我有代码

var image = $("#imgBrandDescription img");
var src=image.attr('src');
image.attr("src",src);
image.error(function(){
   $(this).hide();
}

In Google Chrome,Mozilla,IE9 everything ok,but IE8 it doesn't work.Could you help me please!!! 在谷歌浏览器,Mozilla,IE9中一切正常,但IE8无法正常工作。请您帮我!

FYI, From the jQuery API docs for error(): 仅供参考,从jQuery API文档获取error():

This event may not be correctly fired when the page is served locally. Since error relies
on normal HTTP status codes, it will generally not be triggered if the URL uses the file:
protocol.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM