很小的问题...
问题:当我运行代码时,它没有将输入字段值显示到 div 中,但为什么呢?
要求:我的要求是第一个用户在输入字段中输入值,然后当我单击按钮时,输入值将显示在 div 上。
代码:
function abc(){
window.setInterval(()=>{
var myForm = document.getElementById('myForm');
var text = document.getElementById('text');
text.innerText = myForm.elements['email'].value;
}, 1);
}
<form id="myForm">
<input type="number" name="email" value="user@example.com">
<button id="btn" onclick="abc()">click On me</button>
</form>
<p id='text'></p>
慕容3067478
相关分类