new to JavaScript so please bear with me! I'm stuck in a research rut and not sure on the best way forward with this one
I'm attempting to put together the statement below, but not sure about how to best have the script run again/re-check the if else statement once the TotalPrice value updates.
The TotalPrice dynamic value is within <span class="money"></span> and increases/decreases based on user input (quantityDown & quantityUp +/- DIVs)
var TotalPrice = 0;
if (TotalPrice == 0) {
document.write('<div>PRICE IS 0</div>');
} else {
document.write('<div>PRICE IS NOT 0</div>');
}
<div id="quantityDown_0_0" class="quantity-down" mindx="0_0" vindex="0" onclick="quantityDown(this)"></div>
<div id="quantityUp_0_0" class="quantity-up" mindx="0_0" vindex="0" onclick="quantityUp(this)"></div>
<span class="money">£0</span>
The basic code above is working correctly on the initial page load (producing <div>PRICE IS 0</div>), but once the <span class="money">£0</span> value changes, the else statement is not running
Where I'm at so far...
<span class="money"></span>? That'll
re-run the JavaScript when/if its value changes?I appreciate this is fairly basic JavaScript, so any advice on how to apply this for a learner would be massively appreciated!