This code results in an error at second line ($('boxes div.box'))
<script type="text/javascript">
$(document).ready(function () {
boxes = $('#boxes div.box');
images = $('#images > div');
boxes.each(function (idx) {
$(this).data('image', images.eq(idx));
}).hover(
function () {
boxes.removeClass('active');
images.removeClass('active');
$(this).addClass('active');
$(this).data('image').addClass('active');
});
});
</script>
The error is "Object doesn't 开发者_JAVA百科support this property or method". The same page works fine in Firefox and Chrome.
Anyone?
You need to declare variables with the var
keyword, otherwise IE has no idea where they're coming from and so will just break:
var boxes = $('#boxes div.box');
var images = $('#images > div');
精彩评论