无法在Bootstrap中安装jQuery插件

时间:2014-08-11 10:36:02

标签: jquery css twitter-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网站上无效。有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

您可以使用bootstrap模式:

包含bootstrap jquery文件和css文件

  1. bootstrap.min.css
  2. 自举-theme.min.css
  3. bootstrap.js
  4. bootstrap.min.js
  5. 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>
    

    SCRIPT:

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

    使用此LINK作为参考