在表单页面上显示输入的值,而不单击提交



我正在创建一个form。我怎样才能使input的值显示在表单页面上,而不使用php和JavaScript点击提交按钮

为字段添加一个输入事件监听器,并在需要的地方输出。

const input = document.querySelector("#in");
const output = document.querySelector("#out");
input.addEventListener("input", (e) => {
output.textContent = e.target.value;
});
<p>Type text here: <input id="in" /></p>
<p>See result here: <span id="out"></span></p>