使用适用于jQuery v.2.1.4的bootstrap轮播和适用于jQuery v.1.7.1的prettyPhoto库制作网站。无法找到我的问题的解决方案,noConflict对我不起作用 - 这是代码以及我如何尝试启动js文件:
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="utf-8">
<meta http-equiv= "X-UA-Compatible" content="IE=edge" >
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="css/prettyPhoto.css" rel="stylesheet">
<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<script src="/js/jquery.easing.js"></script>
<script src="/js/galleryScript.js"></script>
<script src="/js/jquery.prettyPhoto.js"></script>
<script src="/js/jquery-1.7.1.min.js"></script>
<script src="/js/jquery-2.1.4.js"></script>
</head>
<body>
<% include partials/template/header.ejs %>
<div class="mainMargin">
<% include partials/template/nav.ejs %>
<% include partials/template/slider.ejs %>
<% include partials/content/main.ejs %>
</div>
<% include partials/template/footer.ejs %>
</body>
</html>
以下是激活插件的js代码:
var jq162 = jQuery.noConflict(true);
jQuery(document).ready(function($)
{
function lightboxPhoto()
{
jQuery("a[rel^='prettyPhoto']").prettyPhoto({
animationSpeed: 'fast',
slideshow: 1000,
theme: 'facebook',
show_title: false,
overlay_gallery: false
});
}
if(jQuery().prettyPhoto)
{
lightboxPhoto();
}
});
答案 0 :(得分:0)
找到了一个解决方案,只是更改了js文件加载的位置,现在看起来如何:
<script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/galleryScript.js"></script>
<script src="/js/jquery.easing.js"></script>
<script src="/js/jquery.prettyPhoto.js"></script>
<script src="/js/scroll.js"></script>