January 2020
Intermediate to advanced
470 pages
11h 13m
English
A similar idea here is instead of removing the event handler, we can disable the button so the user won't be able to click. You might have a function like the following code, which does exactly that by setting the disabled attribute of the button:
function billTheUser(some, sales, data) { document.getElementById("billButton").setAttribute("disabled", "true"); window.alert("Billing the user..."); // actually bill the user}
This also works, but we still have objections as with the previous solutions (coupling the code to the button, needing to re-enable the button, and harder testing), so we don't like this solution either.
Read now
Unlock full access