gpt4 book ai didi

javascript - Bootstrap 模态未启动

转载 作者:行者123 更新时间:2023-11-30 07:25:12 25 4
gpt4 key购买 nike

我是 Bootstrap 的初学者并从中学习 site这是我的代码,当我按下 launch modal 时没有任何反应请告诉我我错过了什么

<!DOCTYPE html>
<html>
<head>
<title>Prices for todo app</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link href="bootstrap-3.0.0/dist/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="bootstrap-3.0.0/dist/css/custom.css" rel="stylesheet" media="screen">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="bootstrap-3.0.0/assets/js/html5shiv.js"></script>
<script src="bootstrap-3.0.0/assets/js/respond.min.js"></script>
<![endif]-->
</head>
<body>
<a class="btn" data-controls-modal="my-modal" data-backdrop="true" >Launch Modal</a>
<form role="form">
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail1" placeholder="Enter email">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password</label>
<input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
</div>
<div class="form-group">
<label for="exampleInputFile">File input</label>
<input type="file" id="exampleInputFile">
<p class="help-block">Example block-level help text here.</p>
</div>
<div class="checkbox">
<label>
<input type="checkbox"> Check me out
</label>
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
<script src="http://code.jquery.com/jquery.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="bootstrap-3.0.0/dist/js/bootstrap.min.js"></script>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
$('#my-modal').modal({
show:true,
closeOnEscape: true
});
</script>
</body>
</html>

最佳答案

我真的建议你不要使用 Twitter Bootstrap v1.3.0,去使用 v2.3.2 或 v3.0.0。

无论如何,Bootstrap Modal 依赖于 HTML,您需要在 HTML 中使用 #my-modal 元素和以下标记。

TB v.1.3.0:

<a class="btn" data-controls-modal="my-modal" data-backdrop="true" >Launch Modal</a>
<div id="my-modal" class="modal hide fade" style="display: none;">
<div class="modal-header"> <a href="#" class="close">×</a>
<h3>Modal Heading</h3>
</div>
<div class="modal-body">
<p>One fine body…</p>
</div>
<div class="modal-footer"> <a href="#" class="btn primary">Primary</a>
<a href="#" class="btn secondary">Secondary</a>
</div>
</div>

TB v.2.3.2:

<a href="#my-modal" role="button" class="btn" data-toggle="modal">Launch demo modal</a>
<div id="my-modal" class="modal hide fade">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>Modal 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>

TB v3.0.0:

<a data-toggle="modal" href="#my-modal" class="btn btn-primary">Launch demo modal</a>
<div class="modal fade" id="my-modal">
<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">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 -->

关于javascript - Bootstrap 模态未启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19380458/

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