简体   繁体   中英

Twitter Bootstrap: Modal to modal switch

I'm using twitter bootstrap and I have a link that opens the modal popup window. Now I want to open another modal popup in the modal itself.

The problem is that this another modal will be opened, but the old one is also still opened. Also the same effect (background gets like 50% darker) applies again, that the background is all black.

Does anyone knows a solution for that?

try this

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM