JSFiddle - React, Tailwind, and code Playground
by koh_edwin
HTML
<button type="button" id="myButton">Click</button>
<button type="button" onclick="TempDisable();">Temp disable</button>
<button type="button" onclick="Enable();">enable</button>
JavaScript
$(function() {
$("#myButton").click(function() {
if ($(this).attr("temp_disable") == "disabled") {
//nothing to do, temporarily disabled...
}
else {
alert("You clicked me!");
}
});
});
function TempDisable() {
$("#myButton").attr("temp_disable", "disabled");
//window.setTimeout(function() { $("#myButton").attr("temp_disable", ""); }, 5000);
}
function Enable() {
$("#myButton").attr("temp_disable", "enabled");
//window.setTimeout(function() { $("#myButton").attr("temp_disable", ""); }, 1000);
}