While debugging some jQuery that is not working in IE, I found this error message:
var item = $("#item_"+ itemArray[itemIndex]).find('a').text().trim();
Object doesn't support this property or method (script.js, line 100, character 2)
The character 2
doesn't make sense to me. Based on the text displayed character 2
would be the letter a
in var
but of course that doesn't make any sense.
(Should I not use var
?)
I know that jQuery is working to some extent or the script would not have been able to get this far on my page.
While debugging some jQuery that is not working in IE, I found this error message:
var item = $("#item_"+ itemArray[itemIndex]).find('a').text().trim();
Object doesn't support this property or method (script.js, line 100, character 2)
The character 2
doesn't make sense to me. Based on the text displayed character 2
would be the letter a
in var
but of course that doesn't make any sense.
(Should I not use var
?)
I know that jQuery is working to some extent or the script would not have been able to get this far on my page.
Share Improve this question asked Nov 30, 2010 at 15:46 Roger BarrRoger Barr 412 bronze badges 4- 2 Why? Because it is Internet Explorer. – user142019 Commented Nov 30, 2010 at 15:49
-
This has been asked before: stackoverflow./questions/2308134/… Basically, it looks like IE does not have
trim()
built-in. – Orbling Commented Nov 30, 2010 at 15:50 - 2 possible duplicate of .trim() in JavaScript not working in IE – Stephen Commented Nov 30, 2010 at 15:52
- @Stephen - That's a non-jQuery question, the optimal answer differs. – Nick Craver Commented Nov 30, 2010 at 16:02
2 Answers
Reset to default 19IE doesn't have String.trim()
, you'll need $.trim()
(which uses native trim if available, emulates it in IE), like this:
var item = $.trim($("#item_"+ itemArray[itemIndex]).find('a').text());
IE doesn't have a trim
method.
Instead, you can call jQuery.trim(...)
.