簡體   English   中英

twitter bootstrap-JS無法正常工作

[英]twitter bootstrap - JS not working

這可能真是愚蠢的問題。 我喜歡boostrap並在相當長的一段時間內使用它的CSS樣式,但是當我嘗試使用他們的任何JS東西時,無論如何它都不適合我。

我總是確保我在標簽中有這個標簽,但仍然

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>   

看來我完全失明了,或者我不知道我一直在做什么錯。 有人可以幫助我嗎?

謝謝。

示例代碼:

   <!DOCTYPE html>
    <html class="no-js">
    <head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <title>Audatex History</title>
        <!-- Latest compiled and minified CSS -->
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">

        <!-- Optional theme -->
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css">

        <!-- Latest compiled and minified JavaScript -->
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>      
    </head>
    <body>
    <button type="button" class="btn btn-lg btn-danger" data-toggle="popover" title="Popover title" data-content="And here's some amazing content. It's very engaging. Right?">Click to toggle popover</button>
    </body>
    </html>

您缺少JQuery

<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>

注意:將其包括在引導JS之前。

而且你必須初始化

<script>
$(function () {
  $('[data-toggle="popover"]').popover()
})
</script>

注意:將其包括在結束標簽頭之前。

Bootstrap依賴jQuery。 在包含引導JS之前先包含它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM