I'm struggling with incorporating a JavaScript function that is required for my school project. The task at hand is to create a store where the price updates dynamically when quantities are added or removed. The +/- buttons are functioning correctly; however, I am facing issues with updating the price displayed in the 'Add' button.
<button class="buttonshad buttonstyling bg-primary text-light mx-5">Add <a id="changingprice">$6.99</a></button>
https://i.sstatic.net/0b45l.png
Below is the JavaScript code I have been using for increasing and decreasing quantity:
function increaseValue() {
value = parseInt(document.getElementById('number').value, 10);
value = isNaN(value) ? 0 : value;
value++;
document.getElementById('number').value = value;
}
function decreaseValue() {
value = parseInt(document.getElementById('number').value, 10);
value = isNaN(value) ? 0 : value;
value < 1 ? value = 1 : '';
value--;
document.getElementById('number').value = value;
}
My main goal is to efficiently update the price displayed in the 'Add' button as quantities are modified.