質問編集履歴
1
code
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,19 +24,21 @@
|
|
24
24
|
|
25
25
|
```html
|
26
26
|
|
27
|
+
<!--cookie保存対象-->
|
28
|
+
|
27
|
-
<div class="post">
|
29
|
+
<div class="post post1">
|
28
30
|
|
29
31
|
<p>title1</p><a href="link1">link1</a>
|
30
32
|
|
31
33
|
</div>
|
32
34
|
|
33
|
-
<div class="post">
|
35
|
+
<div class="post post2">
|
34
36
|
|
35
37
|
<p>title2</p><a href="link2">link2</a>
|
36
38
|
|
37
39
|
</div>
|
38
40
|
|
39
|
-
<div class="post">
|
41
|
+
<div class="post post3">
|
40
42
|
|
41
43
|
<p>title3</p><a href="link3">link3</a>
|
42
44
|
|
@@ -44,9 +46,29 @@
|
|
44
46
|
|
45
47
|
|
46
48
|
|
49
|
+
<!--ここにcookieを出力-->
|
50
|
+
|
47
|
-
<div id="history">
|
51
|
+
<div id="history">
|
52
|
+
|
53
|
+
</div>
|
48
54
|
|
49
55
|
|
56
|
+
|
57
|
+
<!--たとえば、 .post1のクリック時は以下のように出力したい-->
|
58
|
+
|
59
|
+
<div id="history">
|
60
|
+
|
61
|
+
<ul>
|
62
|
+
|
63
|
+
<li><a href="link1">title1<a/></li>
|
64
|
+
|
65
|
+
</ul>
|
66
|
+
|
67
|
+
</div>
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
<!--jQuery.cookieのコード-->
|
50
72
|
|
51
73
|
<script type="text/javascript">
|
52
74
|
|
@@ -64,27 +86,17 @@
|
|
64
86
|
|
65
87
|
var historylink = $(this).find('a').attr('href');
|
66
88
|
|
67
|
-
var history = '<li><a href="'+test_link+'">'+test_title+'</a></li>'
|
68
|
-
|
69
89
|
|
70
90
|
|
71
|
-
// 配列を
|
91
|
+
// 配列にタイトルとリンクを保存
|
72
92
|
|
73
|
-
var params = [];
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
93
|
+
var params = [ { title: '', link: ''} ];
|
78
94
|
|
79
95
|
if($.inArray(history, params) < 0){
|
80
96
|
|
81
|
-
|
97
|
+
params.title.push(historytitle);
|
82
98
|
|
83
|
-
params = $.cookie(history).split(",");
|
84
|
-
|
85
|
-
// 配列に入れる
|
86
|
-
|
87
|
-
params.push(history);
|
99
|
+
params.link.push(historylink);
|
88
100
|
|
89
101
|
}
|
90
102
|
|
@@ -106,7 +118,7 @@
|
|
106
118
|
|
107
119
|
if(cookie){
|
108
120
|
|
109
|
-
$('#history').html('<ul>'+cookie+'</ul>');
|
121
|
+
$('#history').html('<ul><li>'+cookie+'</li></ul>');
|
110
122
|
|
111
123
|
}
|
112
124
|
|
@@ -122,7 +134,7 @@
|
|
122
134
|
|
123
135
|
|
124
136
|
|
125
|
-
単にこうすると登録でき
|
137
|
+
単にこうすると登録できるので、プラグイン自体は作動しているようです。
|
126
138
|
|
127
139
|
|
128
140
|
|