I am trying to make a button I have set up remain inactive until a requirement is met, then after I use the button it becomes inactive. So in my code, I have a money counter that will count up by one every time I click a piece of coal on the screen. I want my button to be inactive until I reach a certain amount of money, then when it's active I want it to be able to do something like replace the coal with another ore. Finally, when I purchase the new ore I want the button to become inactive again until I earn enough money to buy the next upgrade. I don't know if you can use the same button for multiple purchases like I want but I'm just learning to use them thoroughly so it could be possible!
Important Code:
<ul id="one"><strong id="clicks">$<span id="Money">0</span></strong></ul> <!-- Amount of money earned -->
<button type="button" id="upgrade">Upgrade Gem</button> <!-- Button to upgrade gem -->
<script> /* When coal.png is clicked, one unit is added to the money counter */
$(function() {
$('#coal').click(function() {
moneyCalc();
});
function moneyCalc() {
var money = parseInt($("#Money").text());
money = isNaN(money) ? 0: ++money;
$("#Money").text(money);
}
function resetCounter() {
$("#Money").text(0);
}
});
</script>
Thanks ahead of time if you can help me out!