日期:2014-05-17 浏览次数:20573 次
<html>
<head>
<script type="text/javascript">
function update(){
var cnt = document.getElementById("cnt");
cnt.innerHTML = "<input type='text' value=" + cnt.innerHTML + " id='cntInput' onchange='confirmUpdate()'/>";
}
function confirmUpdate(){
var r=confirm("确认修改!");
if (r){
//alert("You pressed OK!");
var newCnt = document.getElementById("cntInput").value;
//alert(newCnt);
var cnt = document.getElementById("cnt");
cnt.innerHTML = newCnt;
}
}
</script>
</head>
<body>
<table border="1">
<tr>
<td id="cnt">123</td>
</tr>
</table>
<br />
<input type="button" onclick=update()
value="修改" />
</body>
</html>