【发布时间】:2015-12-08 08:55:00
【问题描述】:
我在 IE11 中执行这个函数时有一点错误:
function clearText(someText){
return someText.replace(/(\r\n|\n|\r)/gm,"");
}
$.getJSON('/getElements/', callback)
.done(function(fragments){
$.each(fragments, function(propertyName,value){
if (clearText(value.trim())!==""){
$("."+propertyName).empty().append(clearText(value));
//$("."+propertyName).html(clearText(value));
//document.getElementsByClassName(propertyName)[0].innerHTML = clearText(value);
}
});
})
.fail(function(jqXHR, textStatus, errorThrown) {
console.log(textStatus);
});
在所有其他浏览器中,没有问题,empty().append() 有效。但是 IE11 不接受 empty.append 或 .html 或 .innerHTML 我的数组“片段”中还有很多数据。
谁能看出问题出在哪里?
谢谢。
K.
【问题讨论】:
-
你到底遇到了什么错误?
-
IE11 不写任何 HTML 在:$("."+propertyName).empty().append(clearText(value));
-
我们可以看看你的 html 吗? :) IE 比 Chrome 或 Firefox 对 html 错误更敏感。
-
您在控制台中看到任何错误消息吗?如果不是,您的问题标题具有误导性
-
当我使用控制台时,我没有soucy。如果我使用 alert(),我可以看到所有数据
标签: javascript jquery html json getjson