2017-09-19 5 views
0

ダイナミックリンクを生成していますが、リンクをクリックすると、モーダルウィンドウが退色したdivの後ろに表示され、何もクリックできなくなります。私はどのようにそれを閉じることができるように上に表示することができます任意のアイデア?モーダルウィンドウがフェードバックで開く

また、リンクの1つをクリックすると、ページが先頭にジャンプするのを止めることはできますか?スクロール位置を同じにして、ページ上のどこにいるかを調べる必要はありません。どんな助けもありがたい。

<script> 
function showModal(el) { 
jQuery("#myModalLabel").text(el.title); 
jQuery("#myModal").modal() 

} 

</script> 

<a href="#" id="mymodal" onclick="showModal(this)" style="font-size:16px;" 
title="<? echo $row ['title'] ?> 
by 
<? echo $row ['author'] ?>" ><? echo $row ['first_line'] ?> </a> 


<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria- 
labelledby="myModalLabel"> 
<div class="modal-dialog" role="document"> 
<div class="modal-content"> 
    <div class="modal-header"> 
    <button type="button" class="close" data-dismiss="modal" aria- 
label="Close"><span aria-hidden="true">&times;</span></button> 

    </div> 
    <div class="modal-body"> 
    <h4 class="modal-title" id="myModalLabel">Modal title</h4> 
    </div> 
    <div class="modal-footer"> 
    <button type="button" class="btn btn-default" data- 
dismiss="modal">Close</button> 

    </div> 
</div> 
+0

をしようとする外部のコンテナを動かすのに必要な(https://www.w3schools.com/cssref/pr_pos_z-index.asp)をcss-classに追加してください。 –

答えて

0

固定。ただ、ちょうど終了bodyタグ

0

前に、[Zインデックス]を設定してみてください、この1男

HTML

<button type="button" class="btn btn-info btn-lg" data-toggle="modal" id="yourModal" data-target="#myModal" data-title='<? echo $row ["title"] ?> by <? echo $row ["author"] ?> '><? echo $row ['first_line'] ?></button> 

    <!-- Modal --> 
    <div class="modal fade" id="myModal" role="dialog"> 
    <div class="modal-dialog"> 

     <!-- Modal content--> 
     <div class="modal-content"> 
     <div class="modal-header"> 
      <button type="button" class="close" data-dismiss="modal">&times;</button> 
      <h4 class="modal-title" id="myModalLabel">Modal title</h4> 
     </div> 
     <div class="modal-body"> 
      <p>Some text in the modal.</p> 
     </div> 
     <div class="modal-footer"> 
      <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> 
     </div> 
     </div> 

    </div> 
    </div> 

ジャバスクリプト(jqueryの)

 <script> 
    $(document).on("click", "#yourModal", function() { 
     var title = $(this).data('title'); 
      $("#myModalLabel").val(title); 
     }); 

    </script> 
関連する問題