Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 如何在一个html文件中调用两个脚本_Jquery_Html_Flexslider_Prettyphoto - Fatal编程技术网

Jquery 如何在一个html文件中调用两个脚本

Jquery 如何在一个html文件中调用两个脚本,jquery,html,flexslider,prettyphoto,Jquery,Html,Flexslider,Prettyphoto,我是新来的。我正在一个html文件中使用Lightbox和Flexslider。每当我将PrettyTo放在页面底部,就在结束正文标记之前,它就会使我的Flex滑块消失,并且PrettyTo灯箱的配置不正确。我知道这个问题以前有人回答过,但我不明白答案。有人能转告我吗 html文件中包含以下内容: <!-- Javascript --> <script src="/js/jquery.flexslider.js"></script> $(文档).r

我是新来的。我正在一个html文件中使用Lightbox和Flexslider。每当我将PrettyTo放在页面底部,就在结束正文标记之前,它就会使我的Flex滑块消失,并且PrettyTo灯箱的配置不正确。我知道这个问题以前有人回答过,但我不明白答案。有人能转告我吗

html文件中包含以下内容:

<!-- Javascript -->
<script src="/js/jquery.flexslider.js"></script>


$(文档).ready(函数(){
([rel^='prettypto'])。prettypto();
});

在包含jQuery本身之前运行使用jQuery的脚本是行不通的

在函数包含之前,您不能调用它。

您很可能包含多个版本的
jQuery
——每个插件一个版本——这就是问题所在。您可以使用
jQuery.noConflict
,或者执行以下操作:

<script src="jquery-for-plugin1.js"></script>
<script>
    $(function( $ ) {
        //initialize plugin 1
    });
</script>

<script src="jquery-for-plugin2.js"></script>
<script>
    $(function( $ ) {
        //initialize plugin 2
    });
</script>

<script src="jquery-for-plugin3.js"></script>
<script>
    $(function( $ ) {
        //initialize plugin 3
    });
</script>

$(函数($){
//初始化插件1
});
$(函数($){
//初始化插件2
});
$(函数($){
//初始化插件3
});

到底发生了什么?您在控制台中看到了什么?下面是链接:这很有意义。这样我才能正确理解您的意思:我不能调用html文件中不存在的函数,对吗?我继续并试图以这种方式解决它:在下面html文件的底部:$(document).ready(function(){(“a[rel^='prettypoto']).prettypoto();});

否;您只需要在使用jQuery的任何代码之前包含它。您是指jQuery库吗?还是jquery插件?把它放在头上还是身体里?是的,我是。让我试试你的答案。酷。如果您还有任何问题,请告诉我。
<script src="jquery-for-plugin1.js"></script>
<script>
    $(function( $ ) {
        //initialize plugin 1
    });
</script>

<script src="jquery-for-plugin2.js"></script>
<script>
    $(function( $ ) {
        //initialize plugin 2
    });
</script>

<script src="jquery-for-plugin3.js"></script>
<script>
    $(function( $ ) {
        //initialize plugin 3
    });
</script>