- Mastering JavaScript Functional Programming
- Federico Kereki
- 82字
- 2021-07-02 22:41:10
Solution #5 - disable the button
A similar idea: instead of removing the event handler, disable the button, so the user won't be able to click. You might have a function like the following:
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 for the previous solutions (coupling the code to the button, need to re-enable the button, harder testing), so we don't like this solution either.
推薦閱讀
- Advanced Machine Learning with Python
- Java程序設計(慕課版)
- C語言程序設計基礎與實驗指導
- Windows Server 2016 Automation with PowerShell Cookbook(Second Edition)
- 高級語言程序設計(C語言版):基于計算思維能力培養
- 大學計算機基礎實驗指導
- Oracle數據庫編程經典300例
- HTML+CSS+JavaScript網頁制作:從入門到精通(第4版)
- 網頁設計與制作
- C/C++代碼調試的藝術
- PHP典型模塊與項目實戰大全
- Switching to Angular 2
- Python數據科學實戰
- Web應用程序設計:ASP
- Mastering Android Application Development