Skip to content
Advertisement

getting the status of disabled buttons with JS

I have 7 button on a webpage. When i click on btn7, I want to check how many buttons are disabled.

JavaScript

JS

JavaScript

How can I check if all buttons are disabled?

Edit:

I have checked these links but these are advanced and I am not that good with jQuery. JQuery select all elements without disabled AND no readonly?

http://api.jquery.com/disabled-selector/

jQuery: Checking for disabled attribute and adding/removing it?

Advertisement

Answer

Hi CalculatingMachine,

In your example, there was no btn-save7, so I decided to create one. To avoid confusion to readers, I renamed it to Count Buttons.

First select the buttons with a disabled attribute like this button:disabled

Next count them by calling the length property.

Check out this snippet.

JavaScript
JavaScript
Advertisement