我的网页中有两个模态对话,使用Twitter引导,但只有一个有效。
代码如下:

<a href="#format" role="button" class="btn btn-info" data-toggle="format">Phone and Email</a>
<div id="format" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="format" aria-hidden="true">
    <div class="modal-header">
    <!--This needs a fancy phone icon and so does the button.-->
    <img src="img/numberheader.png" alt="">
    </div>
    <div class="modal-body">
    <p>
    <h4>Office:</h4>
    123 4567<br>
    <h4>Programme Manager:</h4>
    765 4321<br>
    <hr>
    <img src="img/emailheader.png" alt="">
    <h4>Email us</h4>Iremovedthemailaddresses<br>
    <a href="Iremovedthemailaddresses" class="btn-primary btn-small">Click Here To Email Us</a>
    <br>
    </p>
    </div>
    <div class="modal-footer">
    <button class="btn btn-info" data-dismiss="modal" aria-hidden="true">Close</button>
    </div>
    </div>
<a href="#myModal" role="button" class="btn btn-info" data-toggle="modal">Phone and Email</a>
<div id="myModal" class="modal hide fade" tabindex="-1"
role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<!--This needs a fancy phone icon and so does the button.-->
<img src="img/numberheader.png" alt="">
</div>
<div class="modal-body">
<p>
<h4>Office:</h4>
123 4567<br>
<h4>Programme Manager:</h4>
765 4321<br>
<hr>
<img src="img/emailheader.png" alt="">
<h4>Email us</h4>Iremovedthemailaddresses<br>
<a href="Iremovedthemailaddresses" class="btn-primary btn-small">Click Here To Email Us</a>
<br>
</p>
</div>
<div class="modal-footer">
<button class="btn btn-info" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
</div>

这两个情态动词的内容还没有被分离成它的意义,它只是在这一点上的概念证明(所以忽略内容)。
但是,它只适用于第二个,而不是第一个。我该怎么做才能让这两种方式都奏效呢?

最佳答案

确保你的锚标签和模态id是唯一的。

<a href="#myModal" role="button" class="btn" data-toggle="modal">Launch demo modal</a>
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

演示:http://jsfiddle.net/uf2UR/

关于html - 如何在一页中获得两种模式对话?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14882051/

10-13 02:36