Twitter Bootstrap Modal does not appear

Twitter Bootstrap Modal does not appear

本文关键字:not appear does Modal Bootstrap Twitter      更新时间:2023-09-26

我使用twitter引导程序创建的任何模式都不会出现。我不确定我做错了什么,因为我使用bootstrap提供的代码设置了一个测试模式,但它仍然不起作用。

这是我的代码(仅限正文):您需要链接到bootstrap.js、bootstrap-modal.js、jquery.js和bootstrap.css

<body>
    <div class="modal hide" id="myModal">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">
                &times;
            </button>
            <h3>Modal header</h3>
        </div>
        <div class="modal-body">
            <p>
                Modal body would go here...
            </p>
        </div>
        <div class="modal-footer">
            <a href="#" class="btn" data-dismiss="modal">Close</a>
            <a href="#" class="btn btn-primary">Save changes</a>
        </div>
    </div>
    <a data-toggle="modal" href="#myModal">Show Modal</a>
</body>

以下是引导模式所需的引导包和jquery的链接:引导程序包jquery

我的问题是我同时包含了boostrap.js和bootstrap-modal.js。显然,如果你包含bootstrap.jsp,你就不应该也包含bootstrap-model.js,因为boostrap.jsp导入了它兼容的所有javascript插件。类似的东西。删除我的boostrap-modal.js脚本链接后,它就工作了。

您必须调用:

<script>
   $('#myModal').modal('show')
</script>

</body>标签之后。或者,如果你只想在用户点击某个东西时调用它:

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