javascript to check button property

PratikShah111
PratikShah111 used Ask the Experts™
on
In my javascript I want to check if a button is enabled or disabled. how can i do that.
Comment
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

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

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