Twitter Bootstrap:模态切换的模态

时间:2013-06-24 10:50:11

标签: javascript twitter-bootstrap

我正在使用twitter bootstrap,我有一个链接可以打开模态弹出窗口。现在我想在模态本身打开另一个模态弹出窗口。

问题是这个另一个模态会被打开,但是旧的模态也会被打开。同样的效果(背景变得像50%更暗)再次适用,背景全黑。

有谁知道解决方案吗?

1 个答案:

答案 0 :(得分:1)

试试这个

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="Styles/bootstrap.css" rel="stylesheet" type="text/css" />

</head>
<body>
    <input type="button" name="name" class="btn btn-danger" value="open first modal" onclick="$('#modal1').modal('show')"/>
    <div class="modal hide fade" id="modal1">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                &times;</button>
            <h3>
                Modal 1 header</h3>
        </div>
        <div class="modal-body">

            <a onclick="$('#modal1').modal('hide');$('#modal2').modal('show');" class="btn btn-success">Open Second modal</a>

        </div>
        <div class="modal-footer">
            <a href="#" class="btn">Close</a> <a href="#" class="btn btn-primary">Save changes</a>
        </div>
    </div>
    <div class="modal hide fade" id="modal2">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                &times;</button>
            <h3>
                Modal 2 header</h3>
        </div>
        <div class="modal-body">
            <p>
                One fine body…</p>
        </div>
        <div class="modal-footer">
            <a href="#" class="btn">Close</a> <a href="#" class="btn btn-primary">Save changes</a>
        </div>
    </div>
    <script src="Scripts/jquery-1.10.1.min.js" type="text/javascript"></script>
    <script src="Scripts/bootstrap.js" type="text/javascript"></script>

</body>
</html>