2009-12-01, 06:07 PM | #1 |
注册日期: 2003-10-22
帖子: 11,052
积分:6
精华:24
现金:14344金币
资产:29325301金币
|
Js点击内容出现文本输入框
HTML 代码:
<script> function Modify(id) { var content = id.innerHTML; id.onclick = null; var tdId = id.id; document.getElementById(tdId).innerHTML = "<input name=n" + tdId + " value=" + content + " />"; } function server(id) { document.getElementById(id).innerHTML = document.getElementsByName("n" + id)[0].value; document.getElementById(id).style.background = "#ff0000"; document.getElementById(id).style.color = "#ffffff"; document.getElementById(id).onclick = function(){ Modify(this); } } </script> <table width="255" height="28" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC" style="font-size:12px; font-family:Arial;"> <tr> <td width="213" height="26" bgcolor="#FFFFFF" id="td_1" onclick="Modify(this)" >修改</td> <td width="39" bgcolor="#FFFFFF" ><a href="#" onclick="server('td_1')">保存</a></td> </tr> </table> |
|