回答編集履歴

1

修正

2017/01/26 00:50

投稿

yambejp
yambejp

スコア114968

test CHANGED
@@ -31,3 +31,59 @@
31
31
  <button type="submit" id="btn">すべて同意して送信</button>
32
32
 
33
33
  ```
34
+
35
+
36
+
37
+ # 追記
38
+
39
+
40
+
41
+ classの処理もありましたね、ではこうで
42
+
43
+ ```
44
+
45
+ <style>
46
+
47
+ .inactive{
48
+
49
+ background-Color:red;
50
+
51
+ }
52
+
53
+ </style>
54
+
55
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
56
+
57
+ <script>
58
+
59
+ $(function(){
60
+
61
+ $("#check1,#check2,#check3").on('change',function(){
62
+
63
+ var flg=$("#check1,#check2,#check3").filter(':checked').length<3;
64
+
65
+ $("#btn")
66
+
67
+ .prop('disabled',flg)
68
+
69
+ .toggleClass('inactive',flg);
70
+
71
+ }).change();
72
+
73
+ });
74
+
75
+ </script>
76
+
77
+
78
+
79
+ <input type="checkbox" name="name1" id="check1"><label for="check1">同意します-1</label>
80
+
81
+ <input type="checkbox" name="name2" id="check2"><label for="check2">同意します-2</label>
82
+
83
+ <input type="checkbox" name="name3" id="check3"><label for="check3">同意します-3</label>
84
+
85
+
86
+
87
+ <button type="submit" id="btn">すべて同意して送信</button>
88
+
89
+ ```