jQuery选择器不工作在IE7 / 8 [英] jQuery selector does not work in IE7/8

查看:91
本文介绍了jQuery选择器不工作在IE7 / 8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人知道为什么这在IE7 / 8中不起作用?

Does anyone know why this would not work in IE7/8?

drop_area = $('div#drop_area');

它可以在IE9,FF2 / 3和Chrome中正常工作。 Internet Explorer 7/8会出现以下错误:

It works perfectly in IE9, FF2/3, and Chrome. Internet Explorer 7/8 gives the following error:

SCRIPT438: Object doesn't support this property or method 

编辑:这是与我的javascript一起使用的HTML:
http://pastebin.com/nwxx8RzW

This is the HTML that goes with my javascript: http://pastebin.com/nwxx8RzW

推荐答案

您在 pastebin 上显示的代码有许多全局变量问题。换句话说,你是编码假设你声明的变量是局部范围,而在现实中,它们是全球性的。示例包括 set box_handle 元素 i id drop_area / code>, row image_id 等。

The code you've shown on pastebin has numerous global variable issues. In other words, you are coding assuming that variables you are declaring are local in scope, whereas in reality they turn out to be global. Examples include set, box_handle, elements, i, id, drop_area, element, row, image_id, etc. All of your functions are global in scope as well, when they can easily be encapsulated in an other function.

现在我不知道是否有一些细微的交互,无论某些代码是否有锤击(全局)数据集通过其他代码,但它似乎似乎有些东西被覆盖,因此方法和属性正在消失。我将开始通过代码并添加 var 到局部变量。接下来,我将在匿名自动执行函数中封装大部分代码。

Now I don't know if there's some subtle interactions going on, whether some code has hammering (global) data set by other code, but it certainly seems as if something is getting overwritten and hence methods and properties are disappearing. I would start by going through the code and adding var to local variables. Next I'd be encapsulating most of this code in an anonymous autoexecuting function.

这篇关于jQuery选择器不工作在IE7 / 8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆