jQuery: How to check if button is disabled

You can use jQuery to trigger a button click from the client.  In this certain situation, I needed to make sure the button was not disabled prior to clicking.  In jQuery you can use the “is” function to check if the button is disabled like this:

<script type="text/javascript">
    $(document).ready(function() {
    if ($('#StartButton').is(':disabled') == false) {


Technorati Tags:


  • $('#StartButton').is(':disabled') == false ???? take out the == false and negate the statement

  • Totally agree with Tony. That is bad practice in English, let alone Javascript. The equivalent to this in the English language is like saying: "If the button is NOT NOT disabled then don't do something"

  • Phil - In Javascript, =, ==, === have different functionality.

    Check the following reference link for info on those and others: https://developer.mozilla.org/en/JavaScript/Reference/Operators/Comparison_Operators

Comments have been disabled for this content.