質問編集履歴

1

javascript記載

2017/09/04 04:59

投稿

natsu69
natsu69

スコア15

test CHANGED
File without changes
test CHANGED
@@ -68,4 +68,116 @@
68
68
 
69
69
 
70
70
 
71
+ ```javascript
72
+
73
+ $(function() {
74
+
75
+ var $children = $('.children');
76
+
77
+ var original = $children.html();
78
+
79
+
80
+
81
+ $('.parent').change(function() {
82
+
83
+
84
+
85
+ var val1 = $(this).val();
86
+
87
+
88
+
89
+ $children.html(original).find('option').each(function() {
90
+
91
+ var val2 = $(this).data('val');
92
+
93
+
94
+
95
+ if (val1 != val2) {
96
+
97
+ $(this).not(':first-child').remove();
98
+
99
+ }
100
+
101
+
102
+
103
+ });
104
+
105
+
106
+
107
+ if ($(this).val() == "") {
108
+
109
+ $children.attr('disabled', 'disabled');
110
+
111
+ } else {
112
+
113
+ $children.removeAttr('disabled');
114
+
115
+ }
116
+
117
+
118
+
119
+ });
120
+
121
+
122
+
123
+ });
124
+
125
+
126
+
127
+ $(function() {
128
+
129
+ var $children = $('.children02');
130
+
131
+ var original = $children.html();
132
+
133
+
134
+
135
+ $('.children').change(function() {
136
+
137
+
138
+
139
+ var val1 = $(this).val();
140
+
141
+
142
+
143
+ $children.html(original).find('option').each(function() {
144
+
145
+ var val2 = $(this).data('val');
146
+
147
+
148
+
149
+ if (val1 != val2) {
150
+
151
+ $(this).not(':first-child').remove();
152
+
153
+ }
154
+
155
+
156
+
157
+ });
158
+
159
+
160
+
161
+ if ($(this).val() == "") {
162
+
163
+ $children.attr('disabled', 'disabled');
164
+
165
+ } else {
166
+
167
+ $children.removeAttr('disabled');
168
+
169
+ }
170
+
171
+
172
+
173
+ });
174
+
175
+
176
+
177
+ });
178
+
179
+ ```
180
+
181
+
182
+
71
183
  ご教授お願い致します。