回答編集履歴
3
Code修正
test
CHANGED
@@ -80,7 +80,7 @@
|
|
80
80
|
|
81
81
|
$.each(initData, function(key, value) {
|
82
82
|
|
83
|
-
$("#foo").prepend('<textarea></textarea><button class="delete">削除</button></li>');
|
83
|
+
$("#foo").prepend('<li><textarea></textarea><button class="delete">削除</button></li>');
|
84
84
|
|
85
85
|
});
|
86
86
|
|
2
追記
test
CHANGED
@@ -23,3 +23,97 @@
|
|
23
23
|
})
|
24
24
|
|
25
25
|
```
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
@追記
|
32
|
+
|
33
|
+
こうだとどうでしょう。
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
```
|
38
|
+
|
39
|
+
/*
|
40
|
+
|
41
|
+
function initialize(){
|
42
|
+
|
43
|
+
$.each(initData, function(key, value) {
|
44
|
+
|
45
|
+
$("#foo").prepend('<li><input type="text"><button class="delete">削除</button></li>');
|
46
|
+
|
47
|
+
});
|
48
|
+
|
49
|
+
}
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
$("#add").click(function() {
|
54
|
+
|
55
|
+
$("#foo").prepend('<li><input type="text"><button class="delete">削除</button></li>');
|
56
|
+
|
57
|
+
localStorage.setItem("foo", $("#foo").html());
|
58
|
+
|
59
|
+
});
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
$("#foo").on("keyup", ":input", function(){
|
64
|
+
|
65
|
+
$.each($("input"), function(key, input){
|
66
|
+
|
67
|
+
$(input).attr("value", $("<div/>").text(input.value).html());
|
68
|
+
|
69
|
+
});
|
70
|
+
|
71
|
+
localStorage.setItem("foo", $("#foo").html());
|
72
|
+
|
73
|
+
});
|
74
|
+
|
75
|
+
*/
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
function initialize(){
|
80
|
+
|
81
|
+
$.each(initData, function(key, value) {
|
82
|
+
|
83
|
+
$("#foo").prepend('<textarea></textarea><button class="delete">削除</button></li>');
|
84
|
+
|
85
|
+
});
|
86
|
+
|
87
|
+
}
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
$("#add").click(function() {
|
92
|
+
|
93
|
+
$("#foo").prepend('<li><textarea></textarea><button class="delete">削除</button></li>');
|
94
|
+
|
95
|
+
localStorage.setItem("foo", $("#foo").html());
|
96
|
+
|
97
|
+
});
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
$("#foo").on("keyup", ":input", function(){
|
102
|
+
|
103
|
+
$.each($("textarea"), function(key, input){
|
104
|
+
|
105
|
+
$(input).text($(input).val())
|
106
|
+
|
107
|
+
});
|
108
|
+
|
109
|
+
localStorage.setItem("foo", $("#foo").html());
|
110
|
+
|
111
|
+
});
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
```
|
116
|
+
|
117
|
+
3つほど関数を修正
|
118
|
+
|
119
|
+
valueじゃなくてDOMそのものをstoreしてたんですね。。。
|
1
コード修正
test
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
|
17
17
|
```
|
18
18
|
|
19
|
-
$("#hoge").on("keyup",function(
|
19
|
+
$("#hoge").on("keyup",function(){
|
20
20
|
|
21
21
|
localStorage.setItem("hoge", $("#hoge").val());
|
22
22
|
|