<div class="htmlarea"> <textarea id="runcode89355"> <meta html-equiv="Content-Type" content="text/HTML; charset=gb2312"> <meta name="author" content="wuleying"> <title>javascript 双击文本框编辑功能代码</title> <style> input.t {border:1px solid #fff;background:#fff;} input.s {border:1px solid #369;background:#fff;} </style> <input class="t" id="test" readonly value="这里是标题,双击文字后实现编辑文本功能"><input type="submit" value="修改" style="display:none;" id="submit"> <script type="text/javascript"> var test = document.getElementById("test"); var mysubmit = document.getElementById("submit"); test.ondblclick = function() { this.readOnly = false; this.className = "s"; //脚本之家说明 主要是通过控制样式来实现文本的样式和文本框样式的切换 mysubmit.style.display = ""; } mysubmit.onclick = function() { test.readOnly = true; test.className = "t"; this.style.display = "none"; } </script> </textarea><br><input onclick="runEx('runcode89355')" type="button" value="运行代码"> <input onclick="doCopy('runcode89355')" type="button" value="复制代码"> <input onclick="doSave(runcode89355)" type="button" value="保存代码">[Ctrl+A 全选 注:<a href="http://www.jb51.net/article/23421.htm" title="查看具体详情" target="_blank">如需引入外部Js需刷新才能执行</a>]</div>