javascript - 我怎样才能在 Twitter Bootstrap 中有两个不同的模式

标签 javascript html css twitter-bootstrap models

因此,如果我有两个不同的模型,则第二个模型中的内容不会显示,而是显示第一个模型的内容。我怎样才能得到两个不同内容的模型

示例模型 1:

<!-- Button to trigger modal -->
<a href="#myModal" role="button" class="btn" data-toggle="modal">modal 1</a>

<!-- Modal -->
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="myModalLabel">Modal header</h3>
  </div>
  <div class="modal-body">
    <p>One fine body…</p>
  </div>
  <div class="modal-footer">
    <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
    <button class="btn btn-primary">Save changes</button>
  </div>
</div>

示例模型 2:

<!-- Button to trigger modal -->
<a href="#myModal" role="button" class="btn btn-danger" data-toggle="modal">modal 2</a>

<!-- Modal -->
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="myModalLabel">this is different</h3>
  </div>
  <div class="modal-body">
    <p>this ones different but yet when you click it the content of the first Model appears.</p>
  </div>
  <div class="modal-footer">
    <button class="btn" data-dismiss="modal" aria-hidden="true">diffent</button>
    <button class="btn btn-danger">Quit</button>
  </div>
</div>

我的目标是当我单击第二个模式按钮时,内容将成为第二个模式中的内容,而不是第一个模式中的内容。我希望它们都不同。

最佳答案

使用 2 个不同的模态 id ....

<!-- Button to trigger modal -->
<a href="#myModal1" role="button" class="btn" data-toggle="modal">modal 1</a>

<!-- Modal -->
<div id="myModal1" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
...

<!-- Button to trigger modal -->
<a href="#myModal2" role="button" class="btn" data-toggle="modal">modal 2</a>

<!-- Modal -->
<div id="myModal2" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
...

Bootply 演示:http://bootply.com/80525

关于javascript - 我怎样才能在 Twitter Bootstrap 中有两个不同的模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18760714/

相关文章:

javascript - 找不到 babel.config.json 中指定的模块

html - z 索引为 -1 的元素位于祖 parent 的 div 之下

javascript - 如何在 JGraph 的流行菜单中设置样式?

jquery - 在 jquery 中使用 addClass 函数时如何在文本上添加颜色悬停

javascript - 最好的多文件 JavaScript/Flash 文件 uploader 是什么?

javascript - 启动 jquery fadeToggle 隐藏

javascript - Leaflet.js/Browser 由于缺少图 block 文件而返回 500 个内部服务器错误

html - CSS 在父鼠标悬停时减轻子元素

html - 图像在容器内不合适并且图像切换没有响应(响应性)

html - 在 HTML 中插入代码片段