Javascript 引导模式未显示
由于某些原因,我无法启动引导模式,下面是我的代码Javascript 引导模式未显示,javascript,jquery,twitter-bootstrap,Javascript,Jquery,Twitter Bootstrap,由于某些原因,我无法启动引导模式,下面是我的代码 <!DOCTYPE html> <html lang="en"> <head> <link href="http://localhost/scripts/bootstrap/css/bootstrap.min.css" rel="stylesheet"> </head> <body> <div
<!DOCTYPE html>
<html lang="en">
<head>
<link href="http://localhost/scripts/bootstrap/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div id="modal" class="modal hide fade">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</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>
<button id="button">Fire</button>
<script src="http://localhost/scripts/bootstrap/js/bootstrap.min.js"></script>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(function(){
$("#button").click(function(){
$('#modal').modal('show');
});
});
</script>
</body>
</html>
&时代;
模态头
一个好身体
火
$(函数(){
$(“#按钮”)。单击(函数(){
$('#model')。model('show');
});
});
您必须在jQuery
库之后包含引导库。您是否费心检查浏览器控制台是否有任何错误?这为我解决了问题。这背后的原因是什么?如果bootstrap本身提供了一个.js文件,为什么我们需要jquery.js?@piperchester bootstrap要求jquery在浏览器中加载/可用,以便它可以修改(添加内容)。例如,Bootstrap网站的“JavaScript”部分中的任何内容都与您可以用来初始化/配置其组件的内容有关;它们是jQuery库的扩展。您可以修改一些不可用的内容,因此需要先加载jQuery。@aHinay Bootstrap提供了它们的库,并且在您下载/使用它时只提供它们的库。如果您想使用他们的JavaScript组件(参见他们的网站),则需要jQuery,因为它们扩展了jQuery。jQuery需要可用,以便引导程序扩展它,所以需要首先加载它。