LoginSignup
135
143

More than 3 years have passed since last update.

[jQuery]input要素にdisabledを設定・解除する方法

Last updated at Posted at 2015-11-18

地味に探しても見つかりづらいので備忘録的に。

けっこう、下のようにattrを使うようなのを見ますが間違いです。
昔は出来たみたいですが、これでは上手く動作しません。

ダメな例

・設定
attr('disabled ','disabled');
・解除
attr('disabled ',false);
とか
attr('disabled ','');

正解例

設定

$("#hoge").prop('disabled', true);

解除

$("#hoge").prop('disabled', false);

まとめ

これで上手くいくハズです。

135
143
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
135
143