js 表格操作(兼容模式

用insertRow,insertRow操作表格时,发现在谷歌浏览器中顺序和IE是反的

// 表格新增行
function addTableRow($id,$arr,$rowAttr){
	var tableObj = document.getElementById($id);
	var tBodyObj = tableObj.tBodies[0];
	var rowObj = document.createElement("tr");
	var cellObj;
	if($rowAttr){
		for(var i=0;i<$rowAttr.length;i++){
			var rowAttribute = ($rowAttr[i]+":").split(":");
			rowObj.setAttribute(rowAttribute[0],rowAttribute[1]);
		}
	}
	for(var i=0;i<$arr.length;i++){
		cellObj = document.createElement("td");
		cellObj.innerHTML = $arr[i];
		rowObj.appendChild(cellObj);
	}
	tBodyObj.appendChild(rowObj);
}

  

原文地址:https://www.cnblogs.com/mouyuan/p/4096585.html