Bootstrap模式不起作用

时间:2017-03-15 10:25:22

标签: twitter-bootstrap

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Addressbook</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="css/style.css" rel="stylesheet">
    <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">

</head>
<body>
    <div class="container">
          <div id="myModal"  role="dialog">
              <div class="modal-dialog" >
                 <!-- Modal content-->
                <div class="modal-content">
                  <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                    <h4 class="modal-title">Add New Contact</h4>
                  </div>
                  <div class="modal-body">
                          <form role="form">
                    <div class="form-group">
                      <label for="firstname"><span class="glyphicon glyphicon-user"></span> Firstname</label>
                      <input type="text" class="form-control" id="firstname" placeholder="Enter Firstname">
                    </div>
                        <div class="form-group">
                      <label for="middlename"><span class="glyphicon glyphicon-user"></span> Middlename</label>
                      <input type="text" class="form-control" id="middlename" placeholder="Enter Middlename">
                    </div>
                        <div class="form-group">
                      <label for="lastname"><span class="glyphicon glyphicon-user"></span> Lastname</label>
                      <input type="text" class="form-control" id="middlename" placeholder="Enter Lastname">
                    </div>
                        <div class="form-group">
                      <label for="phone_number"><span class="glyphicon glyphicon-earphone"></span> Phone Number</label>
                      <input type="text" class="form-control" id="phone_number" placeholder="Enter number">
                    </div>
                      <div class="form-group">
                      <label for="address"><span class="glyphicon glyphicon-home"></span> Addres</label>
                      <input type="text" class="form-control" id="address" placeholder="Enter Addres">
                  </form>
                  </div>
                  <div class="modal-footer">
                    <button type="submit" class="btn btn-success btn-block"><span class="glyphicon glyphicon-plus"></span> Add</button>
                </div>
            </div>
        </div>
    </div>
</div>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <script src="js/script.js"</script>
  <script src="bootstrap/js/bootstrap.js"</script>
  <script src="bootstrap/js/bootstrap.min.js"</script>
  <script src="bootstrap/js/"></script>

</body>
</html>

按钮添加新联系人

<div class="panel-body">
      <div class="pull" ><a href="contacts.php">
       button class="btn btn-successdatatoggle="modal"datatarget="#myModal">
   <span class="glyphicon glyphicon-user"></span> Add New Contact</button></a>   </div>
</div>
它是bootstrap模态结构,不工作任何按钮,我无法理解为什么( 我有按钮添加新的联系人,点击按钮后,我需要创建modal.But点击没有任何发生。按钮在另一页,模态在这个页面。我需要这个模式在另一页,但我不明白如何。

1 个答案:

答案 0 :(得分:0)

您的代码中缺少按钮标记。您的按钮应该是这样的;

<div class="panel-body">
      <div class="pull" >
            <a href="contacts.php">
                    <button type="button" data-toggle="modal" data-target="#myModal"><span class="glyphicon glyphicon-user"></span> Add New Contact</button>
            </a>   
       </div>
</div>