mardi 12 février 2019

How to run alert only once within range in if statement?

function sendWeightAlert(){
 if(petInfo.weight >= 100 && previousWeight < 100){
  $(".treat-button").one("click", function(){
    alert(petInfo.name + " is going obese...");
  });
 }
}

Here basically what I want to do is to display the alert only once when the petInfo.weight is equal or over 100 and stop alerting every time after I click on the treat-button. I have tried to look for the answer and tried everything I could but it's not working... Please help me good code masters!!

Aucun commentaire:

Enregistrer un commentaire