编辑下面的代码:【加编码】
<html> <head> <script> function copyText() { document.getElementById("field2").value=document.getElementById("field1").value; } </script> </head> <body> 字段1: <input type="text" id="field1" value="Hello World!"><br> 字段2: <input type="text" id="field2"> <br><br> <button ondblclick="copyText()">复制文本</button> <p>在按钮双击时触发函数。函数将字段1的文字信息复制到字段2。</p> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂