我想用html和JavaScript編寫一個簡單的計算器,但2 + 2的結果不是4,而是22,請幫助我解決這個問題! 謝謝!HTML和Javascript(正在添加)
<html>
<body>
<input type ="text" id ="x">
<p> + </p>
<input type ="text" id ="y">
<script>
function adder(a,b){
var x = document.getElementById("x").value;
var y = document.getElementById("y").value;
document.getElementById("demo").innerHTML = x+y;
}
</script>
<button type = "button" onclick = "adder(x,y)"> calculate </button>
<p id = "demo"> </p>
</body>
</html>
否決了'Bug' –