Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
525 views
in Technique[技术] by (71.8m points)

internet explorer 8 - jQuery error in IE8 - .val() or 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

}

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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,

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...