jquery - IE7 图像在不应该加载时加载

标签 jquery css debugging internet-explorer-7 cross-browser

我正在构建一个网站,我的一个页面在 IE7 中引起了一些问题。您可以在这里查看该网站:www.vitaminjdesign.com/contact.html

我编写了一个 jquery 脚本,如果联系人字段有条目,它基本上会加载成功图像;如果联系人字段为空,则加载失败图标。它在所有浏览器中都能完美运行,但在 IE7 中,会加载图像占位符。直到加载其中一个图标后它才会消失。只需在 IE7 中查看该页面,您就会明白我的意思。

我确定有一个仅 CSS 的修复程序可以解决此问题,但是如何在 IE7 中删除这些占位符图像?

这是我的 jquery:

$(function(){
    $(':text,:textarea').bind('change, blur',function(){
        $(this).next('img').attr('src',this.value ? 'success.png' : 'fail.png');
    });
});

最佳答案

对于初学者,您可以在它们上设置 display:none ,然后将 $.show(); 添加到绑定(bind)事件内链接的末尾。

<img id="myIcon" style="display:none" />

--

$(":text,:textarea").bind("change, blur", function(){
  $(this).next("img").attr("src",(this.value ? "success.png":"fail.png")).show();
});

关于jquery - IE7 图像在不应该加载时加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1950684/

相关文章:

eclipse - 在 Ubuntu 12.04 LTS + Eclipse Juno 中运行/调试 Openerp7.0

html - 帖子用完了

html - 缩略图不会在 twitter bootstrap 2.3.2 中居中

jquery - plupload 变量上传路径?

javascript - JavaScript 中 RGB 到 HSV 颜色?

html - 如何居中对齐嵌套在列中的列

php - 在 PHP 运行时重命名函数

c++ - boost 文件系统 : recursive_directory_iterator constructor causes SIGTRAPS and debug problems

javascript - 如何在页面呈现之前运行 JavaScript 或 jQuery 脚本

javascript - 使用 window.onload 滚动到特定 div,而不添加网址