日期:2014-05-16 浏览次数:20506 次
<script>
var i=0
function insert_row(){
i ++
R = tbl.insertRow()
C = R.insertCell()
C.innerHTML = "第"+i+"个文件"
C = R.insertCell()
C.innerHTML = "<input>"
C = R.insertCell()
C.innerHTML = "<input type=file>"
C = R.insertCell()
C.innerHTML = "<input type='button' value='删除' onclick='deleteRow(this)'>"
}
function deleteRow(obj){
alert(obj.parentElement.parentElement.rowIndex+1);
tbl.deleteRow(obj.parentElement.parentElement.rowIndex);
}
</script>
var i=0
function insert_row(){
i ++
var tbl=document.getElementById('tbl');//不要用ID访问DOM对象
R = tbl.insertRow(tbl.rows.length)////
C = R.insertCell(0)
C.innerHTML = "第"+i+"个文件"
C = R.insertCell(1)////
C.innerHTML = "<input>"
C = R.insertCell(2)////
C.innerHTML = "<input type=file>"
C = R.insertCell(3)////
C.innerHTML = "<input type='button' value='删除' onclick='deleteRow(this)'>"
}
function deleteRow(obj){
alert(obj.parentElement.parentElement.rowIndex+1);
tbl.deleteRow(obj.parentElement.parentElement.rowIndex);
}