簡體   English   中英

單擊鏈接后無法顯示模式

[英]Unable to display modal on click of link

我試圖在單擊鏈接時打開一個模式。 但是,它沒有打開。 以下是鏈接的代碼:

<div class="span4" style="font-size: 14px">             
   <a href="#" onClick="openModal(); return false;" cssClass="view-more" >Some<br>textlater</a>
</div>

這是模態的代碼

   <div class="modal hide fade" id="myDiv" style="width: 520px;display: block;border: 1px solid black">
 <div class="modal-header" style="width: 517px;"><button type="button" class="close" data-dismiss="modal" aria-hidden="true" >&times;</button></div>    
 <div class="modal-body"">
 <div id="mydiv1" style="text-align:center;">
    <div class="span9"><img alt="img" style="margin-bottom: 10px;padding-top: 2px" src="./images/img.png"></div>
</div>    
</div> 
<div class="modal-footer">
<div class="button-bar-footer">
        <div class="row">
            <div class="pull-left">
                <s:a href="#" cssClass="btn btn-link btn-back" data-dismiss="modal">
                    <span><s:text name="generic.cancel" /></span>
                </s:a>
            </div>
            <div class="pull-right">
             <button type="button" class="btn btn-success" data-dismiss="modal">Close</button>                                  
            </div>
        </div>
  </div>
  </div>
  </div>

這是功能

  <script type="text/javascript">
    function openModal(){
       alert("hello");
       $('myDiv').modal('show');
    }

請問我在哪里想念?

我發現了問題。我在調用show modal之前缺少#。 下面是修改后的代碼

<script type="text/javascript">
   function openModal(){
      alert("hello");
   $('#myDiv').modal('show');
 }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM