7

I'm using json +jquery on client side. I want to disable all buttons found on the page while uploading file. Currently I'm disabling the upload button only using its id as shown below..

$("#upload_attachment_button").addClass('ui-state-disabled');

I wonder if there is a way to disable the rest of the buttons found on the page. I have done a function that I want to use by all the system, and I don't want to send the buttons id every time I want to call this function..

Thanks.

Luci
  • 2,864
  • 6
  • 29
  • 36

1 Answers1

18

It's rather simple. Select all the input elements of the form with type button and disable them:

$("input[type=button]").attr("disabled", "disabled");
Vasilis Lourdas
  • 1,139
  • 16
  • 32
  • so if I want to enable them again, I should do something like this: `$("input[type=button]").attr("disabled", "enabled");` or what, cause this did not work with me. – Luci Sep 29 '10 at 13:49
  • 1
    I used `$("input[type=button]").attr("disabled", false);` and `$("input[type=button]").attr("disabled", true);` – Luci Sep 29 '10 at 14:15
  • 6
    You should use $("input[type=button]").removeAttr("disabled"); – Vasilis Lourdas Sep 29 '10 at 14:58