Jquery 启动模式在单击时不显示
当我尝试在引导中加载模式时,它会在刷新页面时显示,但在单击按钮时不会显示。我希望我的模式仅在用户单击按钮时弹出 我的html文件设置如下:Jquery 启动模式在单击时不显示,jquery,html,css,twitter-bootstrap,modal-dialog,Jquery,Html,Css,Twitter Bootstrap,Modal Dialog,当我尝试在引导中加载模式时,它会在刷新页面时显示,但在单击按钮时不会显示。我希望我的模式仅在用户单击按钮时弹出 我的html文件设置如下: <head> <meta charset="utf-8"> <title>my title here</title> <link rel="stylesheet" type="text/css" href="/static/css/bootstrap.min.css">
<head>
<meta charset="utf-8">
<title>my title here</title>
<link rel="stylesheet" type="text/css" href="/static/css/bootstrap.min.css">
<script src="/static/js/jquery-3.2.1.min.js"></script>
<script src="/static/js/popper.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
<script src="/static/Highcharts-5.0.14/code/highcharts.js"></script>
<script src="/static/Highcharts-5.0.14/code/modules/exporting.js"></script>
<!-- Our Custom CSS -->
<link rel="stylesheet" href="/static/css/style_charts_black.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
</head>
我的头衔在这里
我从引导教程网站复制了以下代码:
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal" style="float:right; margin-right:100px">
Launch demo modal
</button>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="myModalLabel">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<script>$('#myModal').modal('show')</script>
启动演示模式
情态标题
&时代;
...
接近
$('#myModal').modal('show'))
我在javascript控制台中没有得到任何jquery错误。我还尝试将上面的最后一行更改为.modal('toggle'),但没有效果。您的代码很好,您需要将js文件包含在
标记中,而不是头部
根据他们的文件:
在页面末尾添加我们的JavaScript插件、jQuery和Tether,就在结束正文标记之前
以下是我找到该信息的链接:
以及正文中包含的js文件的代码笔,您的代码工作正常:
您的代码工作正常,如果您只想在单击按钮时激活模式,则不需要脚本 $('#myModal').modal('show'))
GSMA智能&mdash;视觉效果
启动演示模式
&时代;
情态标题
...
接近
保存更改
只需删除html标记中的数据切换,然后
写下
$('myModal').modal('show'))
或
$(“#myModal”).modal('toggle')
无需使用此$(“#myModal”).modal('show')启动演示模式此按钮切换id=#myModal的目标元素