###前提・実現したいこと
現在ipop.jsを使い特定の単語をそれぞれクリックするとドラッグ出来るポップアップウィンドウが同時に複数開くようにしています。今回は、2点ほど修正したいのですがやり方がわかりません。
1.クリックした順番にウィンドウが重なるようにしたい。
2.ウィンドウが開いた後、それぞれのウィンドウをクリックすると一番前に出るように設定したい。
今回掲載のコード以外でできる方法があればそれでも構いません。
html
1<!DOCTYPE html> 2<html> 3<head> 4<meta http-equiv="content-type" content="text/html; charset=utf-8"> 5<meta http-equiv="content-style-type" content="text/css"> 6<meta http-equiv="content-script-type" content="text/javascript"> 7<title>jquery ipop_multi.jsのサンプル</title> 8<script type="text/javascript" src="http://www.google.com/jsapi"></script> 9<script type="text/javascript">google.load("jquery", "1.4");</script> 10<script type="text/javascript" src="js/ipop.js"></script> 11<script type="text/javascript"> 12$(function() { 13 $('#open1').click(function() {$("#mado1").ipop();} ); 14 $('#open2').click(function() {$("#mado2").ipop();} ); 15}); 16</script> 17 18<style type="text/css"> 19.ipop { 20 padding: 0; 21 background-color: #fed; 22 width: 300px; 23 height: 200px; 24 border: 1px solid #aaa; 25 26 /* この3行は必須 */ 27 position: absolute; 28 display: none; 29 z-index: 9999; 30} 31 32.ipop_title { 33 background-color: #fdc; 34 cursor: move; 35} 36 37.ipop_close { 38 cursor: pointer; 39 float: right; 40} 41.image { 42 width: 100%; 43 text-align:center; 44} 45 46</style> 47<title>ポップアップウインドウテスト</title> 48</head> 49<body> 50<p>Lorem Ipsum is <a href="#" id="open1">simply</a> dummy text of the printing and <a href="#" id="open2">typesetting</a> industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into <a href="#" id="open3">electronic</a> typesetting, remaining essentially unchanged. <p> 51 52<div class="ipop" id="mado1"> 53 <div class="ipop_close">×</div> 54 <div class="ipop_title">タイトル</div> 55 <p>It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages</p> 56</div> 57<div class="ipop" id="mado2"> 58 <div class="ipop_close">×</div> 59 <div class="ipop_title">タイトル2</div> 60 <p>It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages</p> 61 <div class="image"><img src="http://placehold.jp/24/cc9999/993333/150x100.png"></div> 62</div> 63</body> 64</html>
javascript
1(function($) { 2 $.fn.ipop = function() { 3 4 var $this = $(this); 5 6 var wx, wy; // ウインドウの左上座標 7 var mx, my; // マウスの座標 8 9 // ウインドウの座標を画面中央にする。 10 wx = $(document).scrollLeft() + ($(window).width() - $(this).outerWidth()) / 2; 11 if (wx < 0) wx = 0; 12 wy = $(document).scrollTop() + ($(window).height() - $(this).outerHeight()) / 2; 13 if (wy < 0) wy = 0; 14 15 // ポップアップウインドウを表示する。 16 $this.css('top', wy).css('left', wx).fadeIn(100); 17 18 // 閉じるボタンを押したとき 19 $this.find('.ipop_close').click(function(){ $this.fadeOut(100);}); 20 21 // タイトルバーをドラッグしたとき 22 $this.find('.ipop_title').mousedown(function(e) { 23 mx = e.pageX; 24 my = e.pageY; 25 $(document).mousemove(mouseMove).mouseup(mouseUp); 26 return false; 27 }); 28 function mouseMove(e) { 29 wx += e.pageX - mx; 30 wy += e.pageY - my; 31 $this.css('top', wy).css('left', wx); 32 mx = e.pageX; 33 my = e.pageY; 34 return false; 35 } 36 function mouseUp() { 37 $(document).unbind('mousemove', mouseMove).unbind('mouseup', mouseUp); 38 } 39 } 40})(jQuery); 41
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/12/26 08:20
2016/12/26 09:27
2016/12/27 04:10