回答編集履歴
1
テキスト追加
test
CHANGED
@@ -2,3 +2,19 @@
|
|
2
2
|
|
3
3
|
今回の関数以外にも(今回の関数の下に)checkboxを操作する関数があり、それを$(input[type="checkbox"]').prop('disabled', false);
|
4
4
|
と書いており、これが邪魔しておりました
|
5
|
+
|
6
|
+
また、無名関数で呼び出していたので、以下のように修正しました。
|
7
|
+
```jQuery
|
8
|
+
$(function ()
|
9
|
+
{
|
10
|
+
checkMax();
|
11
|
+
$('.check-max3').click(checkMax);
|
12
|
+
});
|
13
|
+
|
14
|
+
function checkMax() {
|
15
|
+
const checked_length = $('.check-max3:checked').length;
|
16
|
+
// 選択上限は3つまで
|
17
|
+
$('.check-max3:not(:checked)').prop('disabled', 3 <= checked_length);
|
18
|
+
|
19
|
+
}
|
20
|
+
```
|