动态添加删除行

阅读更多
//添加行
function addRow(tableName){
	if(window.ActiveXObject){
		addRowIE(tableName);
	}else{
		addRowFF(tableName);
	}
}
//删除行
function deleteRow(evt,tableName){
	if(window.ActiveXObject){
		deleteRowIE(tableName);
	}else{
		deleteRowFF(evt,tableName);
	}
}
//
function   get_Element(the_ele,the_tag){
	the_tag = the_tag.toLowerCase();
	if(the_ele.tagName.toLowerCase()==the_tag){
		return the_ele;
	}
	while(the_ele=the_ele.offsetParent){
		if(the_ele.tagName.toLowerCase()==the_tag){
			return the_ele;
		}
	}
	return(null);
}
function deleteRowIE(the_table){
	var the_cell;  
	the_cell=get_Element(event.srcElement,"td");  
	var index=the_cell.parentElement.rowIndex;
	if(the_cell==null)   return;   
	if(the_table.rows.length==1)   return;  
	var count=document.getElementById('inputTable').rows.length;
	//先往上移,再删除
	for(var i=index;i 

你可能感兴趣的:(动态添加删除行)