【发布时间】:2021-04-15 11:17:57
【问题描述】:
所以我想从 html 输入中获取整数并在 js 中使用它。
function apply(){
let input = document.getElementById("txtfield").value;
console.log(input);
document.getElementById("txtfield").value = '';
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>stack qustion</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<input id="txtfield">
<button onclick="apply()" id="apply">apply</button>
<script src="script.js"></script>
</body>
</html>
【问题讨论】:
标签: javascript html input textfield