【发布时间】:2023-03-28 21:03:01
【问题描述】:
我想显示单击“Go”按钮时输入的输入值。 输入值存储在名为“value”的变量中,并在 id="show" 中可见。
<html>
<head>
</head>
<body>
<div>
<input type="text" id="input" />
<button onclick="go()">Click</button>
</div>
<div id="show" style="display: none;">
<p>${value}</p>
</div>
<script>
function go() {
document.getElementById('show').style.display = "block";
let value = document.getElementById('input').value;
}
</script>
</body>
</html>
【问题讨论】:
-
或
innerText,或getAttribute等
标签: javascript html