开发者

Why does Internet Explorer not like this jQuery?

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.


IE 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(...).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜