LoginSignup
100
89

More than 5 years have passed since last update.

jqueryでチェックボックスにチェックを入れるにはpropを使え。

Last updated at Posted at 2014-04-22

$('input[name="checkbox"]').attr("checked",true);

ではなくて、

$('input[name="checkbox"]').prop("checked",true);

attrだと挙動が不安定。

理由は調べてないからわからない。

attrは、HTML属性を取得する、propはjavascriptでの属性を取得する。

true か falseはjavascriptでの属性。

100
89
1

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
100
89