Javascript
販売手数料、販売利益の出し方
1. windowがloadされたときにイベント発火
2. const ____ = document.getElementById("id")で入力欄と販売手数料、販売利益の要素を取得する
3. 入力されたときにイベント発火するように関数を定義する。
priceInput.addEventListener("keyup", () => {}); で非同期通信を実行
4.入力された金額を定義
5.条件式if で価格を入力したとき、販売手数料と販売利益が反映されるようにする
function price() {
const priceInput = document.getElementById("item-price"); //金額入力
const add_tax = document.getElementById("add-tax-price"); //販売手数料
const profit = document.getElementById("profit"); //販売利益
priceInput.addEventListener("keyup", () => {
add_tax.textContent = fee;
profit.textContent = gains;
} else {
let fee = ""
let gains = ""
add_tax.textContent = fee;
profit.textContent = gains;
}
});
}
window.addEventListener('load', price);