[英]displaying value of an input on the form page without clicking submit
I'm creating a form
.我正在创建一个
form
。 How can I make the value of an input
display on the form page without clicking the submit button using php and maybe JavaScript如何在不使用 php 和 JavaScript 的情况下单击提交按钮的情况下在表单页面上显示
input
的值
Add an input event listener to the field and output it where needed.将输入事件侦听器添加到字段并在需要的地方输出。
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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.