我需要投入一定數量的蘭特才能取回歐元、英鎊和美元。
我的其余代碼確實具有指向 javascript 檔案的鏈接。我現在只使用了 Dollar() 函式,因為我至少試圖讓一個函式作業,但它沒有,所以我需要幫助。
function dollar() {
let money = document.getElementbyId("rand").value;
const $ = 15.5734;
document.getElementById('result').innerHTML = $ * money;
}
<form>
Rand: <input type="number" id="rand">
<input id="dollar" type="button" onclick="dollar()" value="dollar"/>
<input id="euro" type="button" onclick="euro()" value="euro">
<input id ="pound" type="button" onclick="pound()" value="pound">
</form>
<p> result is: <span id="result"></span> </p>
uj5u.com熱心網友回復:
您只需要更改函式名稱并更改document.getElementbyId
為document.getElementById
<form>
Rand: <input type="number" id="rand">
<input id="dollar" type="button" onclick="todollar()" value="dollar"/>
<input id="euro" type="button" onclick="euro()" value="euro">
<input id ="pound" type="button" onclick="pound()" value="pound">
</form>
<p> result is: <span id="result"></span> </p>
<script>
function todollar() {
let money = document.getElementById("rand").value;
const $ = 15.5734;
document.getElementById('result').innerHTML = $ * money;
}
</script>
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/487292.html
標籤:javascript html 货币