x
 
<!DOCTYPE html>
<html>
<body>
Field1: <input type="text" id="field1" value="Hello World!"><br>
Field2: <input type="text" id="field2"><br><br>
<button onclick="myFunction()">复制文本</button>
<p>单击按钮时会触发一个函数。该函数将文本从 Field1 复制到 Field2。</p>
<script>
function myFunction() {
  document.getElementById("field2").value = document.getElementById("field1").value;
}
</script>
</body>
</html>