In this tutorial, you'll learn how to disable a button with JavaScript. Get my free 32 page eBook of JavaScript HowTos 👉bit.ly/2ThXPL3
The solution to this JavaScript problem is relatively easy but makes an interesting point of practical JavaScript for beginners.
There is a disabled attribute in HTML which can be applied to tags that support it (including buttons). You'll see in this DOM tutorial that we can apply the disabled attribute to a button and it makes it unclickable.
All we really need to do with our JavaScript to disable a button is to set that disabled attribute and also remove it when we want to make the button active again.
To give a more practical JavaScript application of this code we'll create a quick login form that disables the 'Login' button depending on whether the user has entered enough characters into the username and/or password fields.
#practicaljavascript Channel Handle @codebubb
Негізгі бет How To Disable a Button With JavaScript
Пікірлер: 26