Javascript click do stuff once and never again
by t2t2
HTML
<a id="js-linky" href="http://example.com">Test me!</a>
<button id="js-button">Test me too!</button>
JavaScript
$("#js-linky").one("click", function () {
// Do stuff once (eg. ajax request that only should be done once)
alert("Hello and goodbye!")
}).on("click", function () {
return false;
});
$("#js-button").one("click", function () {
// Do stuff once (eg. ajax request that only should be done once)
alert("Hello and goodbye!")
$(this).attr("disabled", "disabled")
}).on("click", function () {
return false;
});