回答編集履歴

1

追記

2017/10/14 15:34

投稿

s8_chu
s8_chu

スコア14731

test CHANGED
@@ -121,3 +121,137 @@
121
121
  </html>
122
122
 
123
123
  ```
124
+
125
+ 追記
126
+
127
+ ---
128
+
129
+ ```HTML
130
+
131
+ <!DOCTYPE html>
132
+
133
+ <html lang="ja">
134
+
135
+ <head>
136
+
137
+ <meta charset="UTF-8">
138
+
139
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.4.0/fullcalendar.min.css">
140
+
141
+ <title>タイトル</title>
142
+
143
+ </head>
144
+
145
+ <body>
146
+
147
+ <div id="calendar"></div>
148
+
149
+ <button type="button" id="button1">クリック</button>
150
+
151
+ <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
152
+
153
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
154
+
155
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.4.0/fullcalendar.min.js"></script>
156
+
157
+ <script>
158
+
159
+ $(function () {
160
+
161
+ var dates = [
162
+
163
+ "2017-05-03",
164
+
165
+ "2017-05-01",
166
+
167
+ "2017-07-01",
168
+
169
+ "2052-01-01",
170
+
171
+ "2017-06-01",
172
+
173
+ "2000-05-01",
174
+
175
+ ];
176
+
177
+
178
+
179
+ function dateClick(d, a, j, v) {
180
+
181
+ var flag = true;
182
+
183
+ $("#calendar").fullCalendar("clientEvents", function (e) {
184
+
185
+ if (moment(d).format("YYYY-MM-DD") === moment(e.start).format("YYYY-MM-DD")) {
186
+
187
+ alert(e.title);
188
+
189
+ flag = false;
190
+
191
+ }
192
+
193
+ });
194
+
195
+ if (flag) {
196
+
197
+ alert("イベントが設定されていない");
198
+
199
+ }
200
+
201
+ }
202
+
203
+
204
+
205
+ $("#calendar").fullCalendar({
206
+
207
+ dayClick: dateClick,
208
+
209
+ events: [{
210
+
211
+ title: "出張",
212
+
213
+ start: "2017-05-01",
214
+
215
+ color: "#92d050"
216
+
217
+ }, {
218
+
219
+ title: "出張2",
220
+
221
+ start: "2017-06-01",
222
+
223
+ color: "#92d050"
224
+
225
+ }, {
226
+
227
+ title: "出張3",
228
+
229
+ start: "2017-07-01",
230
+
231
+ color: "#92d050"
232
+
233
+ }]
234
+
235
+ });
236
+
237
+
238
+
239
+ $("#button1").on("click", function () {
240
+
241
+ $.each(dates, function (i, v) {
242
+
243
+ dateClick(v);
244
+
245
+ });
246
+
247
+ });
248
+
249
+ });
250
+
251
+ </script>
252
+
253
+ </body>
254
+
255
+ </html>
256
+
257
+ ```