JavaScript
- 1 ответ
- 0 вопросов
1
Вклад в тег
<input type="button" id="buttonCountPlus" value="+">
<input type="button" id="buttonCountMinus" value="-">
<div id="buttonCountNumber">1</div>
<input type="hidden" value="1" id="num" name="num">
let buttonCountPlus = document.getElementById("buttonCountPlus");
let buttonCountMinus = document.getElementById("buttonCountMinus");
let count = document.getElementById("buttonCountNumber");
let count2 = document.getElementById("num");
let number = 1;
let price = 350;
buttonCountPlus.onclick = function() {
if (number <= 3) {
number++;
count.innerHTML = number;
count2.value = number * price;
}
};
buttonCountMinus.onclick = function() {
if (number >= 2) {
number--;
count.innerHTML = number;
count2.value = number * price;
}
}: