IE8中的jQuery错误 - .val()或trim()? [英] jQuery error in IE8 - .val() or trim()?

查看:176
本文介绍了IE8中的jQuery错误 - .val()或trim()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在IE8调试器中遇到jquery错误,但我不确定是哪个函数导致它。我在这里看到一大堆帖子说IE8不支持native trim(),但我不是(我不认为)使用本机版本(我继承了这段代码;它不是我写的东西从零开始。)

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

}

错误我进入调试器是在启动new_email的行;错误是对象不支持此属性或方法。

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."

任何人都可以帮我弄清楚1)IE8不支持哪些属性或方法,以及2 )我能做些什么来解决它?我绝不是一个jquery专家;我是99%的服务器端。

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.

该代码适用于Chrome,Safari和Firefox。

The code does work in Chrome, Safari, and Firefox.

推荐答案

<更新:
由于新的信息,我认为你遇到了IE的一个问题,当你有一个变量和一个ID为同名的元素时会发生冲突会导致冲突和混乱的错误消息功能性没有出口。有关更详细的说明,请参阅此参考。 http://www.karlstanley.net/blog/?p=5

原始答案:
如果您在调试单个复杂行时遇到问题,请将其拆分为多个部分,

Original Answer: If you are having problems debugging a single complex line split it into parts,

var tempValue = $(":text", row).val();
new_email = jQuery.trim(tempValue);

这篇关于IE8中的jQuery错误 - .val()或trim()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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