我正在做一個簡單的形式,使用函數「multiply」乘以輸入,但它不起作用。請有人幫助我。還有一個想法,我們什麼時候爲函數添加參數? 我的代碼是:java腳本乘法函數
<html>
<head>
<title></title>
<style>
#resultDiv {
font-size: 24pt;
text-align: center;
color: green;
font-weight: bold;
}
</style>
</head>
<body>
<input type="text" id="firstnum">
<input type="text" id="secondtnum">
<button onclick="calculate()"> press here </button>
<div id="resultDiv"></div>
<script>
function multiply() {
return firstnum * secondnum;
}
function displayInResultDiv(v){
document.getElementById("resultDiv").innerHTML=v;
}
function calculate(){
var firstnum=document.getElementById("firstNum").value;
var secondnum=document.getElementById("secondNum").value;
var result=firstnum * secondnum;
displayInResultDiv(result);
}
</script>
</body>
</html>
'firstnum'與'firstNum'不同,'secondtnum'與'secondNum'不同。由於錯別字而投票結束。請在問問題之前下次使用瀏覽器控制檯。 – Xufox
對不起,我只是一個初學者:)不知道如何從控制檯查看它。 –