簡體   English   中英

無法在Bootstrap中安裝jQuery插件

[英]Trouble installing jQuery plugin in Bootstrap

我正在嘗試在我的網站中包括一個用於彈出窗口的jQuery插件。 我下載了fancybox插件,並在<head>包含以下代碼:

<link rel="stylesheet" href="colorbox.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="jquery.colorbox.js"></script>
<script>
    $(document).ready(function(){
        //Examples of how to assign the Colorbox event to elements
        $(".group1").colorbox({rel:'group1'});
    });
</script>

以及<body>的以下代碼:

<a class="group1" href="../content/myimage.jpg"><img src="../content/myimage.jpg" width="30px" height="50px"</a>

但是沒有出現彈出窗口。 我嘗試在單個網頁中單獨運行此代碼,並且該代碼可以完美運行,但是在我的Bootstrap網站上無法正常運行。 有人可以幫忙嗎?

您可以使用引導模式:

包括bootstrap jquery文件和css文件

  1. bootstrap.min.css
  2. 自舉theme.min.css
  3. bootstrap.js
  4. bootstrap.min.js

HTML:

<!-- Button trigger modal -->
<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" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h4 class="modal-title" id="myModalLabel">Modal title</h4>
      </div>
      <div class="modal-body">

         <a class="group1" href="../content/myimage.jpg"><img src="../content/myimage.jpg" width="30px" height="50px"/></a>

      </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>

腳本:

$('#myModal').modal('show');

使用此鏈接作為參考

暫無
暫無

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

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