bootstrap 4模态错误?

时间:2017-07-08 18:46:09

标签: jquery twitter-bootstrap bootstrap-4 tether

  <html><body><div class="modal fade" id="myModal">
  <div class="modal-dialog modal-xl" role="document">
  <div class="modal-content">Hello Modal</div></div></div>


  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"></script>

  <script> function showModal { $('#myModal').modal('show') }</script>
  </body></html>

调用showModal时:

  

未捕获的TypeError:$(...)。modal不是函数

我做错了什么?

1 个答案:

答案 0 :(得分:1)

您的代码应如下所示

 <script> function showModal() { $('#myModal').modal('show'); };</script>

应该没事的