javascript to check button property

PratikShah111 used Ask the Experts™
In my javascript I want to check if a button is enabled or disabled. how can i do that.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
created a variable and checked its value instead
Most Valuable Expert 2017
Distinguished Expert 2018

Why not just check the disabled property on the button
<button id="buttonId' disabled>Disabled Button</button>
var btn = document.getElementById('buttonId');
if (btn.disabled) {
   alert('Button is disabled');
} else {
   alert('Button is NOT disabled');

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial