我试过了,noConflict行不通

noConflict is not working in any way i tried

本文关键字:noConflict 行不通 过了      更新时间:2023-09-26

使用jQuery v.2.1.4的bootstrap carousel和jQuery v.1.7.1的pretypto库制作站点。无法找到解决我的问题,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();
    }
});

找到了解决方案,只是改变了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>