我的网页上有两个模态对话,使用Twitter-bootstrap,但只有一个有效。
以下是代码:
<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>
这两个模态的内容还没有分成它的意思,它只是当时的概念证明(所以忽略内容)。
然而,它只适用于第二个,而不是第一个。我能做些什么才能使两个模态都有效?
答案 0 :(得分:2)
确保您的锚标记和模态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">