You are not hiding your button on click, you are using setTimeout(granjero, 1000);
The if is only called every seconds, so it will only hide if the granjero called.
Question
My buttons react to be "hidden" very slowly when I click them. The problem is that user have time to click it more times. What can I do for have "hidden" faster?
Here you have the webpage: http://coatbridgeonline.net/testing/tests/game/index.php
The webpage uses cookies (you can save or delete them by a button inside it).
EDIT:
when you clic food's "+1" appear a new button called farmer.
EDIT:
function farmer(){
document.getElementById("BFarmer").style.visibility="hidden";
refreshfood();
}
function refreshfood(){
if (food>=foodprice){
document.getElementById("BFarmer").style.visibility="visible";
}}
<body onload="farmer(); refreshfood()" style="padding-left: 3%">
<div style="height:40px">
<button id="BFarmer" onclick="refreshfood(); farmer()" style="visibility:hidden">Farmer</button>
</div>
La solution
You are not hiding your button on click, you are using setTimeout(granjero, 1000);
The if is only called every seconds, so it will only hide if the granjero called.