添加删除div之类的
1 var my = document.getElementById("myDiv"); 2 var myParent = my.parentNode; 3 if(my != null) 4 { 5 my.parentNode.removeChild(my); 6 } 7 var myNew = document.createElement("myDiv"); 8 myNew.id = "scorePanel"; 9 myParent.appendChild(myNew);
页面列表动态插入新行:
if(valueItems.length>0) { for( i=0; i<valueItems.length; i++) { var item = valueItems[i]; so_mark = item['SO_MARK'].value; so_id = item['SO_ID'].value; so_name = item['SO_NAME'].value; rz_score = item['RZ_SCORE'].value; khdxScoreArr[i] = so_id; sc[i] = rz_score; if( rz_score=="null" ) { rz_score=""; } // 插入变化后的新行 var newTr = scoreTable.insertRow(); newTr.style.backgroundColor = '#dde7ef'; var newTd0 = newTr.insertCell(); // 新行的第一列 var newTd1 = newTr.insertCell(); var newTd2 = newTr.insertCell(); newTd0.innerText = so_mark; // 第一列赋值 newTd1.innerText = so_name; newTd0.style.height = 34; newTd2.innerText = rz_score; } }