var dbRefObjectHis = firebase.database().ref('Box1').child('history');
dbRefObjectHis.on('value',gotData, errData);
function gotData(data) {
var ref = d3.selectAll('.His');
for (var i = 0; i < ref.length; i++){
ref[i].remove();
}
var history = data.val();
var keys = Object.keys(history);
for (i = 0; i < keys.length; i++) {
var k = keys[i];
var humidity = history[k].humidity;
var temperature = history[k].temperature;
$('.His').append('Humidity:' + humidity + 'Temperature:' + temperature );
}
答案 0 :(得分:1)
当您要删除的元素不是可移动节点时,会发生这种情况。
尝试替换
for (var i = 0; i < ref.length; i++){
ref[i].remove();
}
使用
ref.forEach(function(e) {
e.remove();
});