当这个页面打开时,我的模态会自动出现

时间:2015-02-24 10:07:50

标签: html twitter-bootstrap

点击按钮即可。 但问题是,当页面打开时,它会自动出现,而我想只在按钮点击时才会出现这种情况。                测试模式                                 

    <div class="col-md-2"><center/><button class="btn btn-lg" data-toggle="modal" data-target="#myModal">TIME ZONE</button> </div>

    <div class="modal fade" id="myModal" tabindex="-1" role="dialog"     aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> &times; </button>
                    <h4 class="modal-title" id="myModalLabel">
                    Time Zone            </h4> 
                </div> 
                <div class="modal-body">
                Add some text here      
                </div>   
            <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
            </div>
        </div>


    <script>    $(function () { $('#myModal').modal({       keyboard: true    })}); </script>


    <script src="js/bootstrap.js"></script>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

试试这个。

<input type="button" id="btn"/>

$(function () { 
    $("#btn").click(function(){
         $('#myModal').modal('show');
    });

});