如何通过JS将一种形式的文本框内容复制到另一种形式的文本框

how to copy contents from one textbox in one form to another textbox in another form through JS

<form action="formoneaction" method="post">
  <input type="text" id="t1" />
  <button type="sumbit" class="btn">Insert</button>
</form>

<form action="formtwoaction" method="post">
  <input type="text" id="t2" />
  <button type="sumbit" class="btn">Insert</button>
</form>

<script>
    var t1 = document.getElementById('t1');
    t1.onkeyup = t1.onchange = function() {
      document.getElementById('t2').value = this.value;
    };
</script>

当两个元素处于不同的形式时,如何让脚本工作?该脚本在 none 个表单中有效时有效。

我从来没有学过JS,所以当别人解释一堆行话时,我可能不是很理解。抱歉,我会尽力的!

试试下面的代码,它将数据从 textbox 复制到 TextArea:

$("#textArea").append("\n * " + $("#textBox").val());

Working Demo