这是代码,更改 jQ 插件的背景图像,在 Chrome、FF、Safari 甚至我的两部智能手机上运行良好。但不是IE。谁能发现问题吗?
<script type="text/javascript">
$(document).ready(function() {
$("#supersized img").attr({
src: "images/bg2.jpg",
});
$("#supersized").attr($("img"));
});
</script>
最佳答案
IE对其对象字面量的构成非常严格。很多时候它不喜欢你在最后一个属性后面加上逗号。因此,在这种情况下,src
属性后面的逗号将适合 IE,尤其是 IE 6 和 7
$("#supersized img").attr({
src: "images/bg2.jpg" //<-- notice no comma after property value because it's the last one.
});
$("#supersized").attr($("img"));
});
关于javascript - 为什么任何版本的 IE 都不能处理这个 Javascript?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4846952/