Home  >  Article  >  Web Front-end  >  Javascript implements dynamic addition and deletion of table rows (compatible with IE/FF)_javascript skills

Javascript implements dynamic addition and deletion of table rows (compatible with IE/FF)_javascript skills

WBOY
WBOYOriginal
2016-05-16 19:16:011080browse

nbsp;HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">


Dynamic addition and deletion of table rows

























基本信息
其它信息  
     
     


<script> <BR><!-- <BR>//author: Robin <BR>//email: griefforyou@gmail.com <br><br>var rowIndex=0; <BR>function addLine(obj){ <BR>var objSourceRow=obj.parentNode.parentNode; <BR>var objTable=obj.parentNode.parentNode.parentNode.parentNode; <BR>if(obj.value=='增加'){ <BR>rowIndex++; <BR>var objRow=objTable.insertRow(rowIndex); <BR>var objCell; <br><br>objCell=objRow.insertCell(0); <BR>objCell.innerHTML=" "; <br><br>objCell=objRow.insertCell(1); <BR>objCell.innerHTML=objSourceRow.cells[1].innerHTML; <br><br>objCell=objRow.insertCell(2); <BR>objCell.innerHTML=objSourceRow.cells[2].innerHTML.replace(/增加/,'删除'); <BR>} <BR>else{ <BR>objTable.lastChild.removeChild(objSourceRow); <BR>rowIndex--; <BR>} <BR>} <br><br>function removeLine(){ <br><br>} <br><br>//--> <BR></script>
Basic information
Other information
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn