gpt4 book ai didi

jquery - Bootstrap : TypeError: $(. ..).modal 不是函数

转载 作者:行者123 更新时间:2023-12-03 21:57:55 26 4
gpt4 key购买 nike

我一直在尝试从 jquery 调用 bootstrap 模式并不断收到此错误消息:

TypeError: $(...).modal is not a function

这是我的代码:

<button id="btnTest" class="btn btn-default">Show Modal</button>
<div id="dummyModal" role="dialog" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" data-dismiss="modal" class="close">&times;</button>
<h4 class="modal-title">Error</h4>
</div>
<div class="modal-body">
<p>Quick Brown Fox Jumps Over The Lazy Dog</p>
</div>
<div class="modal-footer">
<button type="button" data-dismiss="modal" class="btn btn-default">Close</button>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="/js/jquery-1.11.3.js"></script>
<script type="text/javascript" src="/js/bootstrap.js"></script>
<script type="text/javascript">
$('document').ready(function () {
$('#btnTest').click(function () {
$('#dummyModal').modal('show');
});
});
</script>

仅供引用,我使用 bootstrap 3.3.5 和 jquery 1.11.3。我试过jQuery.noConflict(); ... etc来自this thread但仍然没有运气。这是complete code

最佳答案

用这个。它会起作用的。我使用过 bootstrap 3.3.5jquery 1.11.3

$('document').ready(function() {
$('#btnTest').click(function() {
$('#dummyModal').modal('show');
});
});
body {
background-color: #eee;
padding-top: 40px;
padding-bottom: 40px;
}
<!DOCTYPE html>
<html>

<head>
<meta charset="utf8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<title>Modal Test</title>
</head>

<body>
<div class="container">
<button id="btnTest" class="btn btn-default">Show Modal</button>
<div id="dummyModal" role="dialog" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" data-dismiss="modal" class="close">&times;</button>
<h4 class="modal-title">Error</h4>
</div>
<div class="modal-body">
<p>Quick Brown Fox Jumps Over The Lazy Dog</p>
</div>
<div class="modal-footer">
<button type="button" data-dismiss="modal" class="btn btn-default">Close</button>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</body>

</html>

关于jquery - Bootstrap : TypeError: $(. ..).modal 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32326074/

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