专注前端素材!
源代码:
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>素材8网教程(study.sucai8.cn)</title> <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>
运行结果