我的 html 输入数字值在我的 JS 代码中无法识别,它会提醒什么都没有。如果我想制作另一个代码,也会发生同样的事情
var age = document.getElementById("ent").value;
document.getElementById("press").onclick = function() {
alert(age);
}Run Code Online (Sandbox Code Playgroud)
<input type="number" id="ent">
<button id="press">seed</button>Run Code Online (Sandbox Code Playgroud)