在调试一些在 IE 中不工作的 jQuery 时,我发现了这个错误信息:
var item = $("#item_"+ itemArray[itemIndex]).find('a').text().trim();
Object doesn't support this property or method (script.js, line 100, character 2)
字符 2
对我来说没有意义。根据显示的文本,字符 2
将是 var
中的字母 a
,但这当然没有任何意义。
(我不应该使用 var
吗?)
我知道 jQuery 在某种程度上可以正常工作,否则脚本无法在我的页面上运行这么远。
最佳答案
IE 没有 String.trim()
, 你需要 $.trim()
(如果可用,它使用原生 trim ,在 IE 中模拟它),像这样:
var item = $.trim($("#item_"+ itemArray[itemIndex]).find('a').text());
关于javascript - 为什么 Internet Explorer 不喜欢这个 jQuery?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4315570/