回答編集履歴
1
回答内容の追加
answer
CHANGED
@@ -4,4 +4,23 @@
|
|
4
4
|
$('label.checkbox').on('clicke', function(){
|
5
5
|
$(input).prop('form_agree','agree')
|
6
6
|
});
|
7
|
+
```
|
8
|
+
|
9
|
+
---
|
10
|
+
2019-07-04 19:18 追記
|
11
|
+
修正後も動かないのは、$.html() で追加した要素に対して、イベントのセットが効いていないものと思います。
|
12
|
+
下記のように、要素を追加した後でイベントをセットしたら動くようにならないでしょうか?
|
13
|
+
( $(input).prop('form_agree', 'agree') の部分でエラーが出るとは思います。)
|
14
|
+
|
15
|
+
```javascript
|
16
|
+
/* .confirm__agree書き換え*/
|
17
|
+
$(function () {
|
18
|
+
$('.confirm__agree').html('<label class="checkbox"><input type="checkbox" name="form_agree" value="agree"></label><label class="checkbox_text"><a href="/mobile/xxxxxx-xxxxxx/" target="_blank" style="color: blue; text-decoration: underline;">規約</a>に同意します</label>');
|
19
|
+
|
20
|
+
/* label.checkboxが押されたら checkboxをtureにする */
|
21
|
+
$('label.checkbox').on('click', function () {
|
22
|
+
$(input).prop('form_agree', 'agree')
|
23
|
+
});
|
24
|
+
//↑ ブロックの内側に入れて、順番に処理が走るようにする
|
25
|
+
});
|
7
26
|
```
|