回答編集履歴

3

インデント修正

2016/10/14 09:39

投稿

yambejp
yambejp

スコア114843

test CHANGED
@@ -134,7 +134,7 @@
134
134
 
135
135
  - もう一度押すと、チェックボックスが外れて表示が消える
136
136
 
137
- -「キャンセル」「登録」が表示されている状態で、どちらかをクリックすると、テストボタンや画像をクリックしても閉じなくなる
137
+ - 「キャンセル」「登録」が表示されている状態で、どちらかをクリックすると、テストボタンや画像をクリックしても閉じなくなる
138
138
 
139
139
  - 「キャンセル」「登録」をもう一度おすと閉じることができるようになる
140
140
 

2

まとめ

2016/10/14 09:39

投稿

yambejp
yambejp

スコア114843

test CHANGED
@@ -121,3 +121,141 @@
121
121
  </table>
122
122
 
123
123
  ```
124
+
125
+
126
+
127
+ # まとめたVer
128
+
129
+ 以下、そのままHTMLにコピペしてみてください
130
+
131
+ 仕様:
132
+
133
+ - テストボタン1,3,5および隣の画像をおすと、チェックボックスがチェックされて「キャンセル」「登録」が表示される
134
+
135
+ - もう一度押すと、チェックボックスが外れて表示が消える
136
+
137
+ -「キャンセル」「登録」が表示されている状態で、どちらかをクリックすると、テストボタンや画像をクリックしても閉じなくなる
138
+
139
+ - 「キャンセル」「登録」をもう一度おすと閉じることができるようになる
140
+
141
+
142
+
143
+ 上記仕様ではないようでしたらどういう挙動を想定しているか指示してください
144
+
145
+
146
+
147
+ ```HTML
148
+
149
+ <style>
150
+
151
+ input[type=checkbox] + div{display:none;}
152
+
153
+ input[type=checkbox]:checked + div{display:block;}
154
+
155
+ </style>
156
+
157
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
158
+
159
+ <script>
160
+
161
+ $(function(){
162
+
163
+ $('div.oo-cont2').find('a').on('click',function(){
164
+
165
+ $(this).parents('td').find('label').attr('for',function(index,prop){return (r=prop.match(/^stop_(.+?)$/))?r[1]:"stop_"+prop});
166
+
167
+ });
168
+
169
+ });
170
+
171
+ </script>
172
+
173
+ <table>
174
+
175
+ <tr>
176
+
177
+ <td colspan="3">
178
+
179
+ <div class="objectopen">
180
+
181
+ <label for="oo-cap1">
182
+
183
+ <img src="xxx.png">テストボタン1</a>
184
+
185
+ </label>
186
+
187
+ <a href="">テストボタン2</a>
188
+
189
+ </div>
190
+
191
+ <input id="oo-cap1" type="checkbox">
192
+
193
+ <div class="oo-cont2">
194
+
195
+ <a href="#">キャンセル</a><a href="#">登録</a>
196
+
197
+ </div>
198
+
199
+ </td>
200
+
201
+ </tr>
202
+
203
+ <tr>
204
+
205
+ <td colspan="3">
206
+
207
+ <div class="objectopen">
208
+
209
+ <label for="oo-cap2">
210
+
211
+ <img src="xxx.png">テストボタン3</a>
212
+
213
+ </label>
214
+
215
+ <a href="">テストボタン4</a>
216
+
217
+ </div>
218
+
219
+ <input id="oo-cap2" type="checkbox">
220
+
221
+ <div class="oo-cont2">
222
+
223
+ <a href="#">キャンセル</a><a href="#">登録</a>
224
+
225
+ </div>
226
+
227
+ </td>
228
+
229
+ </tr>
230
+
231
+ <tr>
232
+
233
+ <td colspan="3">
234
+
235
+ <div class="objectopen">
236
+
237
+ <label for="oo-cap3">
238
+
239
+ <img src="xxx.png">テストボタン5</a>
240
+
241
+ </label>
242
+
243
+ <a href="">テストボタン6</a>
244
+
245
+ </div>
246
+
247
+ <input id="oo-cap3" type="checkbox">
248
+
249
+ <div class="oo-cont2">
250
+
251
+ <a href="#">キャンセル</a><a href="#">登録</a>
252
+
253
+ </div>
254
+
255
+ </td>
256
+
257
+ </tr>
258
+
259
+ </table>
260
+
261
+ ```

1

修正

2016/10/14 07:31

投稿

yambejp
yambejp

スコア114843

test CHANGED
@@ -40,6 +40,62 @@
40
40
 
41
41
  <div class="objectopen">
42
42
 
43
+ <label for="oo-cap1">
44
+
45
+ <img src="xxx.png">テストボタン1</a>
46
+
47
+ </label>
48
+
49
+ <a href="">テストボタン2</a>
50
+
51
+ </div>
52
+
53
+ <input id="oo-cap1" type="checkbox">
54
+
55
+ <div class="oo-cont2">
56
+
57
+ <a href="#">キャンセル</a><a href="#">登録</a>
58
+
59
+ </div>
60
+
61
+ </td>
62
+
63
+ </tr>
64
+
65
+ <tr>
66
+
67
+ <td colspan="3">
68
+
69
+ <div class="objectopen">
70
+
71
+ <label for="oo-cap2">
72
+
73
+ <img src="xxx.png">テストボタン1</a>
74
+
75
+ </label>
76
+
77
+ <a href="">テストボタン2</a>
78
+
79
+ </div>
80
+
81
+ <input id="oo-cap2" type="checkbox">
82
+
83
+ <div class="oo-cont2">
84
+
85
+ <a href="#">キャンセル</a><a href="#">登録</a>
86
+
87
+ </div>
88
+
89
+ </td>
90
+
91
+ </tr>
92
+
93
+ <tr>
94
+
95
+ <td colspan="3">
96
+
97
+ <div class="objectopen">
98
+
43
99
  <label for="oo-cap3">
44
100
 
45
101
  <img src="xxx.png">テストボタン1</a>
@@ -48,9 +104,9 @@
48
104
 
49
105
  <a href="">テストボタン2</a>
50
106
 
107
+ </div>
108
+
51
109
  <input id="oo-cap3" type="checkbox">
52
-
53
- </div>
54
110
 
55
111
  <div class="oo-cont2">
56
112
 
@@ -64,6 +120,4 @@
64
120
 
65
121
  </table>
66
122
 
67
-
68
-
69
123
  ```