我在 IE8 调试器中收到 jquery 错误,但我不确定是哪个函数导致的。我在这里看到一大堆帖子说IE8不支持原生trim(),但我没有(我不认为)使用原生版本(我继承了这段代码;这不是我写的东西从头开始。)
这是导致问题的块 - 它是单击功能的一部分:
greenlight = false;
link = $(this);
href = $(this).attr("href");
row = $(this).parent().parent();
if ($(":text", row).exists()) {
new_email = jQuery.trim($(":text", row).val());
//do stuff here
}
我在调试器中遇到的错误位于以 new_email 开头的行上;错误是“对象不支持此属性或方法。”
谁能帮我弄清楚 1) IE8 不支持哪些属性或方法,以及 2) 我可以做些什么来修复它?我绝不是 jquery 专家;我99%都是服务器端的。
该代码可以在 Chrome、Safari 和 Firefox 中运行。
I'm getting a jquery error in the IE8 debugger but I'm not sure which function is causing it. I've seen a whole bunch of posts here that state that IE8 doesn't support native trim(), but I'm not (I don't think) using a native version (I inherited this code; it's not something I wrote from scratch.)
Here's the chunk that's causing issues - it's part of a click function:
greenlight = false;
link = $(this);
href = $(this).attr("href");
row = $(this).parent().parent();
if ($(":text", row).exists()) {
new_email = jQuery.trim($(":text", row).val());
//do stuff here
}
The error I'm getting in the debugger is on the line starting new_email; the error is "Object doesn't support this property or method."
Can anyone help me figure out 1) which property or method IE8 doesn't support, and 2) what I can do to fix it? I'm in no way a jquery expert; I'm 99% server-side.
The code does work in Chrome, Safari, and Firefox.
发布评论
评论(2)
更新:
由于新的信息,我认为您遇到了 IE 的问题,当您有一个变量和一个具有相同名称的元素 ID 时,它会发生冲突,这会导致冲突和关于功能不存在的令人困惑的错误消息。请参阅此参考以获取更详细的解释。 http://www.karlstanley.net/blog/?p=5
原始答案:
如果您在调试单个复杂线路时遇到问题,请将其分成几部分,
Update:
Due to new information, I think you come accross an issue with IE where it will have a conflict when you have a variable and a element IDed with the same name it will cause conflicts and confusing error messages about functinality not exitsting. See this reference for a more detailed explanation. http://www.karlstanley.net/blog/?p=5
Original Answer:
If you are having problems debugging a single complex line split it into parts,
更改:
据我所知,
jQuery 库中没有
exists()
函数(尝试搜索 API 参考)。Change:
To:
There's no
exists()
function in the jQuery library as far as I know (tried searching the API reference).