问题遇到的现象和发生背景
原本第一行点击修改按钮不能 变为确认按钮并调用函数
新增的订单可以
用代码块功能插入代码,请勿粘贴截图
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
body {
font-size: 13px;
line-height: 25px;
}
table {
border-top: 1px solid #333;
border-left: 1px solid #333;
width: 400px;
}
td {
border-right: 1px solid #333;
border-bottom: 1px solid #333;
text-align: center;
}
.title {
font-weight: bold;
background-color: #cccccc;
}
.addRow{
width: 70px;
}
input{
width: 40px;
}
</style>
</head>
<body>
<table cellspacing="0" cellpadding="0" id="order">
<tr class="title">
<td>商品名称</td>
<td>数量</td>
<td>价格</td>
<td>操作</td>
</tr>
<tr>
<td>防滑真皮休闲鞋</td>
<td>12</td>
<td>¥568.50</td>
<td><input type="button" value="删除" onclick="delRow(this)" />
<input type="button" value="修改" onclick="editRow(this)" />
</td>
</tr>
<tr>
<td colspan="4" style="height:30px;">
<input type="button" value="增加订单" onclick="addRow()" class="addRow"/>
</td>
</tr>
</table>
</body>
<script type="text/javascript">
var table=document.getElementById('order');
function addRow(){
var rowIndex=table.rows.length-1; //新插入行在表格中的位置
var newRow=table.insertRow(rowIndex);
var col1=newRow.insertCell(0);
var col2=newRow.insertCell(1);
var col3=newRow.insertCell(2);
var col4=newRow.insertCell(3);
col1.innerHTML='抗疲劳神奇钛项圈';
col2.innerHTML='1';
col3.innerHTML='¥49.00';
col4.innerHTML="<input type='button' value='删除' onclick='delRow(this)'/> <input type='button' value='修改' onclick='editRow(this)'/>"
}
function delRow(obj){
var row=obj.parentNode.parentNode.rowIndex;
table.deleteRow(row);
}
function editRow(obj){
var tdobj = obj.parentNode.parentNode.cells;
var num=tdobj[1].innerHTML;
tdobj[1].innerHTML= "<input id='new' type='text' value="</span>+num+<span class="hljs-string">"/>";
tdobj[1].firstChild.focus();
tdobj[1].firstChild.select();
tdobj[3].lastChild.value ="确定";
tdobj[3].lastChild.setAttribute("onclick","Conf(this)");
}
function Conf(obj){
var tdobj = obj.parentNode.parentNode.cells;
var num=tdobj[1].firstChild.value;
tdobj[1].innerHTML = num;
tdobj[3].lastChild.value ='修改';
tdobj[3].lastChild.setAttribute("onclick","editRow(this)");
}
</script>
</html>
###### 运行结果及报错内容
![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/559029782766165.png "#left")
![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/817879782766120.png "#left")
![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/930399782766143.png "#left")