我尝试使用 JavaScript 自动计算找零,当我在付款中输入一些数字时,找零输入将自动填充找零
<!DOCTYPE html>
<html>
<body>
subtotal: <input type="number" id="subtotal" value="20000">
pay : <input type="number" id="dibayar" onkeyup="kembalian()">
<p>change: <span id="demo"></span></p>
<script>
function kembalian() {
var x = document.getElementById("subtotal").value;
var y = document.getElementById("dibayar").value;
var awe = x - y;
console.log(awe);
document.getElementById("kembalian").innerHTML = awe;
}
</script>
</body>
</html>
繁星点点滴滴
精慕HU
慕桂英4014372
相关分类