回答編集履歴
4
修正
test
CHANGED
@@ -190,7 +190,7 @@
|
|
190
190
|
|
191
191
|
**複数ポップアップ対応版**
|
192
192
|
|
193
|
-
と
|
193
|
+
このようにすることで複数にも対応できると思います。
|
194
194
|
|
195
195
|
```HTML
|
196
196
|
|
@@ -206,7 +206,7 @@
|
|
206
206
|
|
207
207
|
<meta charset='UTF-8'>
|
208
208
|
|
209
|
-
<title></title>
|
209
|
+
<title>タイトル</title>
|
210
210
|
|
211
211
|
<style type='text/css'>
|
212
212
|
|
@@ -254,6 +254,8 @@
|
|
254
254
|
|
255
255
|
let $popUp = $(".popUp");
|
256
256
|
|
257
|
+
let $this = $popUp.prev("a");
|
258
|
+
|
257
259
|
|
258
260
|
|
259
261
|
$popUp.css({
|
@@ -268,7 +270,7 @@
|
|
268
270
|
|
269
271
|
|
270
272
|
|
271
|
-
$
|
273
|
+
$this.mouseover(function () {
|
272
274
|
|
273
275
|
$(this).next(".popUp").fadeIn();
|
274
276
|
|
@@ -280,9 +282,9 @@
|
|
280
282
|
|
281
283
|
$(this).next(".popUp").css({
|
282
284
|
|
283
|
-
|
285
|
+
"top": e.pageY + 10 + "px",
|
284
|
-
|
286
|
+
|
285
|
-
|
287
|
+
"left": e.pageX + 10 + "px"
|
286
288
|
|
287
289
|
});
|
288
290
|
|
3
修正
test
CHANGED
@@ -252,9 +252,7 @@
|
|
252
252
|
|
253
253
|
$(document).ready(function () {
|
254
254
|
|
255
|
-
|
255
|
+
let $popUp = $(".popUp");
|
256
|
-
|
257
|
-
const $this = $popUp.prev("a").next();
|
258
256
|
|
259
257
|
|
260
258
|
|
@@ -280,7 +278,7 @@
|
|
280
278
|
|
281
279
|
}).mousemove(function (e) {
|
282
280
|
|
283
|
-
$this.css({
|
281
|
+
$(this).next(".popUp").css({
|
284
282
|
|
285
283
|
'top': e.pageY + 10 + 'px',
|
286
284
|
|
@@ -290,7 +288,7 @@
|
|
290
288
|
|
291
289
|
});
|
292
290
|
|
293
|
-
})
|
291
|
+
});
|
294
292
|
|
295
293
|
</script>
|
296
294
|
|
2
追記
test
CHANGED
@@ -185,3 +185,117 @@
|
|
185
185
|
</html>
|
186
186
|
|
187
187
|
```
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
**複数ポップアップ対応版**
|
192
|
+
|
193
|
+
とりあえずこれで複数にも対応できると思います。
|
194
|
+
|
195
|
+
```HTML
|
196
|
+
|
197
|
+
<!DOCTYPE HTML>
|
198
|
+
|
199
|
+
<html lang='ja'>
|
200
|
+
|
201
|
+
<!-- https://teratail.com/questions/61908 -->
|
202
|
+
|
203
|
+
<!-- 参考 http://qiita.com/ShibuyaKosuke/items/8c47ae51195ddc42ce67 -->
|
204
|
+
|
205
|
+
<head>
|
206
|
+
|
207
|
+
<meta charset='UTF-8'>
|
208
|
+
|
209
|
+
<title></title>
|
210
|
+
|
211
|
+
<style type='text/css'>
|
212
|
+
|
213
|
+
.popUp {
|
214
|
+
|
215
|
+
border: 2px solid #000000;
|
216
|
+
|
217
|
+
padding: 10px;
|
218
|
+
|
219
|
+
}
|
220
|
+
|
221
|
+
</style>
|
222
|
+
|
223
|
+
</head>
|
224
|
+
|
225
|
+
<body>
|
226
|
+
|
227
|
+
テキストテキストテキスト
|
228
|
+
|
229
|
+
<a href="javascript:void(0)">
|
230
|
+
|
231
|
+
クリックすると吹き出しがでる
|
232
|
+
|
233
|
+
</a>
|
234
|
+
|
235
|
+
<span class="popUp">吹き出しテキスト1</span>
|
236
|
+
|
237
|
+
<hr>
|
238
|
+
|
239
|
+
テキストテキストテキスト
|
240
|
+
|
241
|
+
<a href="javascript:void(0)">
|
242
|
+
|
243
|
+
クリックすると吹き出しがでる
|
244
|
+
|
245
|
+
</a>
|
246
|
+
|
247
|
+
<span class="popUp">吹き出しテキスト2</span>
|
248
|
+
|
249
|
+
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
|
250
|
+
|
251
|
+
<script>
|
252
|
+
|
253
|
+
$(document).ready(function () {
|
254
|
+
|
255
|
+
const $popUp = $(".popUp");
|
256
|
+
|
257
|
+
const $this = $popUp.prev("a").next();
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
$popUp.css({
|
262
|
+
|
263
|
+
opacity: "0.8",
|
264
|
+
|
265
|
+
position: "absolute",
|
266
|
+
|
267
|
+
display: "none"
|
268
|
+
|
269
|
+
});
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
$("a").mouseover(function () {
|
274
|
+
|
275
|
+
$(this).next(".popUp").fadeIn();
|
276
|
+
|
277
|
+
}).mouseout(function () {
|
278
|
+
|
279
|
+
$(this).next(".popUp").fadeOut();
|
280
|
+
|
281
|
+
}).mousemove(function (e) {
|
282
|
+
|
283
|
+
$this.css({
|
284
|
+
|
285
|
+
'top': e.pageY + 10 + 'px',
|
286
|
+
|
287
|
+
'left': e.pageX + 10 + 'px'
|
288
|
+
|
289
|
+
});
|
290
|
+
|
291
|
+
});
|
292
|
+
|
293
|
+
})
|
294
|
+
|
295
|
+
</script>
|
296
|
+
|
297
|
+
</body>
|
298
|
+
|
299
|
+
</html>
|
300
|
+
|
301
|
+
```
|
1
修正
test
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
0. ```var $this = $popUp.next("a");```というようにすれば可能ではないでしょうか?
|
4
4
|
|
5
|
-
0. 動作する記述の場合の$(this)の使い方はあっていると思います
|
5
|
+
0. 動作する記述の場合の$(this)の使い方はあっていると思います。間違っていれば動かないのではないかと思います。
|
6
6
|
|
7
7
|
|
8
8
|
|