在调试一些在 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)
The character 2
对我来说没有意义。根据显示的文本character 2
将是这封信a
in var
但这当然没有任何意义。
(我不应该使用var
?)
我知道 jQuery 在某种程度上正在发挥作用,否则脚本将无法在我的页面上实现这一点。
IE没有String.trim() https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/Trim, 你需要$.trim() http://api.jquery.com/jQuery.trim/(如果可用,则使用本机修剪,在 IE 中模拟它),如下所示:
var item = $.trim($("#item_"+ itemArray[itemIndex]).find('a').text());
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)