Javascript 是否有替代innerHTML的方法黑莓浏览器问题
是否有替代innerHTML的方法黑莓浏览器问题 黑莓4.6浏览器似乎没有正确使用innerHTML。 它不是替换内容,而是附加内容Javascript 是否有替代innerHTML的方法黑莓浏览器问题,javascript,blackberry,innerhtml,Javascript,Blackberry,Innerhtml,是否有替代innerHTML的方法黑莓浏览器问题 黑莓4.6浏览器似乎没有正确使用innerHTML。 它不是替换内容,而是附加内容 function load_activities(){ x$('#dummy').xhr('program.php',{ method:'post', data: 'action=list'. callback: function(){ document.getElement
function load_activities(){
x$('#dummy').xhr('program.php',{
method:'post',
data: 'action=list'.
callback: function(){
document.getElementById("status2").innerHTML = this.responseText;
}
});
克隆没有子节点的节点,然后添加新内容如何
callback: function () {
var status2 = document.getElementById("status2");
var copy = status2.cloneNode(false); // false indicates to not copy children
copy.innerHTML = this.responseText;
if (status2.nextSibling) { // put the copy in the same place as the existing node
var refchild = status2.nextSibling;
status2.parentNode.removeChild(status2);
refchild.parentNode.insertBefore(copy, refchild);
}
else { // existing node is the last child, copy can be appended to the end of the list
var parent = status2.parentNode;
parent.removeChild(status2);
parent.appendChild(copy);
}
}
我没有办法测试这一点,所以我不确定
cloneNode
是否能按预期工作,只复制标记和属性。希望有帮助。如果将innerHTML设置为空字符串,会发生什么?它还保留旧东西吗?