为什么没有任何版本的IE处理此Javascript? [英] Why won't any version of IE process this Javascript?
本文介绍了为什么没有任何版本的IE处理此Javascript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是代码,更改了jQ插件的背景图片,在Chrome,FF,Safari甚至我的两部智能手机上都可以正常工作.但不是IE.任何人都可以发现问题吗?
This is the code, changing a background image for a jQ plugin, Works fine on Chrome, FF, Safari and even my two smart phones. But not IE. Can anyone spot a problem?
<script type="text/javascript">
$(document).ready(function() {
$("#supersized img").attr({
src: "images/bg2.jpg",
});
$("#supersized").attr($("img"));
});
</script>
推荐答案
IE在其对象文字形式上非常严格.很多时候,您不希望在最后一个属性后加上逗号.因此,在这种情况下,src
属性后的逗号将使IE适合,最著名的是IE 6& 7
IE is very strict on its object literal formation. Many times it does not like you to put a comma after the last property. So in this instance the comma after your src
property will give IE fits, most notoriously 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"));
});
这篇关于为什么没有任何版本的IE处理此Javascript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文