gpt4 book ai didi

javascript - Bootstrap 模式将页面变成空 Canvas

转载 作者:行者123 更新时间:2023-11-28 08:02:56 24 4
gpt4 key购买 nike

我的引导模式在使用 data-toggle="modal"data-target="chart" 时正常工作,但是当我使用 javascript .modal() 打开模式时它将页面变成全白。

HTML:

    <div id="myModal">
<div class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body">
<p>One fine body&hellip;</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</div>

JavaScript:

    var base = $('#myModal');
base.modal();
//i even tried base.modal("show")

最佳答案

您的 ID 属性 myModal必须放入您的 <div class="modal">元素。

以下代码可以工作:

<div class="modal fade" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
</button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body">
<p>One fine body&hellip;</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->


<!-- Button trigger modal -->
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
Launch demo modal
</button>


<script type="text/javascript">
$('#myModal').modal('show');
</script>

关于javascript - Bootstrap 模式将页面变成空 Canvas ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25155219/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com