Bootstrap模态对话框不起作用

时间:2015-07-31 15:36:49

标签: javascript jquery twitter-bootstrap modal-dialog

我正在学习一些Bootstrap,我在模态对话框中遇到了一些问题。我已经从Bootstrap复制并粘贴了源代码,当我在计算机上启动相同的代码时,它无法正常工作。我搜索了一些主题,但我找不到答案。这是我的代码:

<!doctype html> 
<html>
<title>Bootstrap</title>
<meta http-equiv="Content-Type" content="text/html; charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"  
<!-- Bootstrap -->
<link href="bootstrap/css/botstrap.min.css" rel="stylesheet">
<script src="bootstrap/js/bootstrap.js"></script>

<head>
<body>
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
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">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
            <span aria-hidden="true">&times;</span>
            </button>
            <h4 class="modal-title" id="myModalLabel">Modal title</h4>
         </div>
         <div class="modal-body">
         ...
         </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>
   </div>
</div>

1 个答案:

答案 0 :(得分:1)

您需要添加jQuery库

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>


<!-- Button trigger modal -->
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
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">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
            <span aria-hidden="true">&times;</span>
            </button>
            <h4 class="modal-title" id="myModalLabel">Modal title</h4>
         </div>
         <div class="modal-body">
         ...
         </div>
         <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal"Close>Close</button>
            <button type="button" class="btn btn-primary">Save changes</button>
         </div>
     </div>
   </div>
</div>