我正在尝试在我的网站中为弹出窗口添加一个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网站上无效。有人可以帮忙吗?
答案 0 :(得分:0)
您可以使用bootstrap模式:
包含bootstrap jquery文件和css文件
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">×</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作为参考