日期:2014-05-16 浏览次数:20363 次
<script type="text/javascript">
function dele(id){
var docu=document.getElementById(id).rowIndex;
document.getElementById("table1").deleteRow(docu);
}
function upd(id,a){
var v=document.getElementById("t1").rowIndex;
}
</script>
</head>
<body>
<table id="table1" border="1px">
<tr style="text-align:center; font-weight:bold;">
<td>商品名称</td>
<td>数量</td>
<td>单价</td>
<td>操作</td>
</tr>
<tr id="tr2">
<td>玫瑰保湿睡眠面膜</td>
<td>5</td>
<td>¥48</td>
<td><input type="button" value="删除" onclick="dele('tr2')"/>
<input id="t1" type="button" value="修改" onchange="upd('tr2',this)" /></td>
</tr>
<tr style="text-align:center">
<td colspan="4"><input type="button" value="增加订单" /></td>
</tr>
</table>
<style>
#price{width:100%;border:none }
</style>
<script type="text/javascript">
function dele(id){
var docu=document.getElementById(id).rowIndex;
document.getElementById("table1").deleteRow(docu);
}
function upd(id,a){
var td=a.parentNode.parentNode.getElementsByTagName('td')['priceTd']
var input=td.getElementsByTagName('input')[0] ;
var v=td.innerHTML.match(/\d+/)
------解决方案--------------------
0;
if(!input ){
var w=td.offsetWidth-2;
td.innerHTML= '<input id="price" />';
var input=td.getElementsByTagName('input')[0] ;
input.style.width=w +'px';
input.value=v;
input.focus();
}
}
</script>
</head>
<body>
<table id="table1" border="1px">
<tr style="text-align:center; font-weight:bold;">
<td>商品名称</td>
<td>数量</td>
<td&g