<html> <head> <script type="text/javascript"> function setToInput(){ var oNode=event.srcElement; if(oNode.childNodes.length<1) return; var oInput=document.createElement("INPUT"); oInput.type="text"; oInput.οnblur=setToTD; oInput.size=5; oNode.appendChild(oInput); oInput.value=oNode.innerText; oNode.childNodes[0].removeNode(); oInput.focus(); oInput.select(); } function setToTD(){ var oNode=event.srcElement; if(oNode.tagName=="INPUT"){ var oValue=document.createTextNode(oNode.value); if(oValue&&oValue.nodeValue){ oNode.parentNode.innerText = oValue.nodeValue; }else{ oNode.parentNode.innerText = " "; } oNode.removeNode(); } } </script> </head> <body> <h5>可编辑的表格</h5> <table border=1> <tr> <td height='25px' width='50px' align='center' οnclick="setToInput();">0</td> <td width='30px' οnclick="setToInput();">2</td> </tr> <tr> <td οnclick="setToInput();">2</td> <td οnclick="setToInput();">2</td> </tr> </table> </body> </html>