gpt4 book ai didi

jquery - 在 Bootstrap 中安装 jQuery 插件时遇到问题

转载 作者:太空宇宙 更新时间:2023-11-03 18:02:20 25 4
gpt4 key购买 nike

我正在尝试在我的网站中包含一个用于弹出窗口的 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 模式:

包括bootstrap jquery文件和css文件

  1. bootstrap.min.css
  2. bootstrap-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');

使用这个 LINK供引用

关于jquery - 在 Bootstrap 中安装 jQuery 插件时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25241248/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com