【发布时间】:2020-07-28 03:58:47
【问题描述】:
function convertion() {
let inputValue = number(document.getElementById('firstValue').value);
let result = document.getElementById('secondValue');
result.innerHTML = inputValue * 10;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1" />
</head>
<body>
<main>
<label for="firstValue">dm: </label>
<input id="firstValue" type='number'>
<button onclick="convertion()">
CONVERT
</button>
<br/>
<br/>
<label for="secondValue">cm: </label>
<input id="secondValue" readonly>
</main>
</body>
</html>
let inputValue = number(document.getElementById('firstValue').value)
【问题讨论】:
-
我喜欢有人用不相关的线程标记为重复
-
MostafaShaker,你需要注意错误。尝试运行您提供的代码 sn-p,您会得到一个 - sn-p 引擎会为您提供它,但您需要注意它们的开发时间。这就是为什么它像@J那样关闭。 Gandra - 真正的问题是,如何将我的字符串更改为数字。
-
他的错误是尝试使用innerHTML 访问输入的值,就像@DCR 指出的那样。无需将数字更改为字符串。
标签: javascript html