怎样让你的表格可编辑???

[入库:2005年8月18日] [更新:2007年3月25日]

本文简介:选择自 net_lover 的 blog

 

怎样让你的表格可编辑???

出处:http://go.163.com/colorweb

欢迎光临 [孟宪会之精彩世界] http://lucky.myrice.com

代码如下:

<html> <head> <style> .td1 { color: white; background-color: orange;} .td2 { color: white; background-color: #0099ff;} .td3 { color: white; background-color: #336699;} </style> <script> function editcell (cell) { if (document.all) { cell.innerhtml = '<input id="editcell" onclick="event.cancelbubble = true;" onchange="setcell(this.parentelement, this.value)" onblur="setcell(this.parentelement, this.value)" value="' + cell.innertext + '" size="' + cell.innertext.length + '">'; document.all.editcell.focus(); document.all.editcell.select(); } else if (document.getelementbyid) { cell.normalize(); var input = document.createelement('input'); input.setattribute('value', cell.firstchild.nodevalue); input.setattribute('size', cell.firstchild.nodevalue.length); input.onchange = function (evt) { setcell(this.parentnode, this.value); }; input.onclick = function (evt) { evt.cancelbubble = true; if (evt.stoppropagation) evt.stoppropagation(); }; cell.replacechild(input, cell.firstchild); input.focus(); input.select(); } } function setcell (cell, value) { if (document.all) cell.innertext = value; else if (document.getelementbyid) cell.replacechild(document.createtextnode(value), cell.firstchild); } </script> </head> <body> <table border="2"> <tr> <td onclick="editcell(this);" class="td1">欢迎光临</td> <td onclick="editcell(this);" class="td2">[孟宪会之精彩世界]</td> <td onclick="editcell(this);" class="td3">http://lucky.myrice.com</td> </tr> </table> </body> </html>

本文关键:javascript,table,孟宪会
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top