Languages
[Edit]
EN

JavaScript - disable multiple inputs on click

0 points
Created by:
trincot
360

In this article, we would like to show you how to disable multiple inputs on click using JavaScript.

Quick solution:

 

Practical example

Edit

In this example, we disable multiple checkbox inputs using:

  • document.querySelectorAll() - to get all input elements,
  • forEach() - to iterate over the input elements and set each element's disable property to true.

Runnable example:

2. Disable / enable buttons with text inputs

Edit

In this example, we use the same method as above to disable text type inputs. Additionally, we create a new button that can enable them again.

References

Edit
  1. Document.querySelector() - Web APIs | MDN
  2. HTMLSelectElement.disabled - Web APIs | MDN
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join