Jquery Fancybox没有';不工作,图像在同一窗口中打开
我试图让fancybox工作,但我能让它工作。我一直在搜索论坛,但我无法找到有助于我理解我做错了什么的答案。也许没必要说,但我是jQuery的真正初学者 我有这样一个代码:Jquery Fancybox没有';不工作,图像在同一窗口中打开,jquery,html,fancybox,Jquery,Html,Fancybox,我试图让fancybox工作,但我能让它工作。我一直在搜索论坛,但我无法找到有助于我理解我做错了什么的答案。也许没必要说,但我是jQuery的真正初学者 我有这样一个代码: $(文档).ready(函数(){ $(“.fancybox”).fancybox(); }); 当我有一个简短的代码时,它工作得很好。有人能告诉我我做了什么吗?我是如何解决的 Thanx。由于两个jquery版本,存在jquery冲突。 There is a jquery conflict, because of
$(文档).ready(函数(){
$(“.fancybox”).fancybox();
});
当我有一个简短的代码时,它工作得很好。有人能告诉我我做了什么吗?我是如何解决的
Thanx。由于两个jquery版本,存在jquery冲突。
There is a jquery conflict, because of two jquery versions.
Add all your js file to the bottom and in the following order just before </body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="js/modernizr.js"></script> <!-- Modernizr -->
<script type="text/javascript" src="js/jquery.fancybox.pack.js?v=2.1.5"></script> <!-- fancybox -->
<script src="js/main.js"></script> <!-- Resource jQuery -->
<script type="text/javascript">
$(document).ready(function() {
$(".fancybox").fancybox();
});
</script>
Please remove all javascripts from the head section.
so your head section looks like :-
<head>
<title>Alternate Fixed And Scroll Backgrounds</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href='http://fonts.googleapis.com/css?family=Roboto:400,700,300' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="http://psteintj.home.xs4all.nl/css/reset.css"> <!-- CSS reset -->
<link rel="stylesheet" href="http://psteintj.home.xs4all.nl/css/style.css"> <!-- Resource style -->
<link rel="stylesheet" href="http://psteintj.home.xs4all.nl/css/jquery.fancybox.css?v=2.1.5" type="text/css" media="screen" /> <!-- fancybox -->
</head>
将所有js文件添加到底部,然后按以下顺序添加
$(文档).ready(函数(){
$(“.fancybox”).fancybox();
});
请从head部分删除所有Javascript。
所以你的头部看起来像:-
交替固定和滚动背景
我没有提到firebug说:TypeError:$(…).fancybox不是一个函数$(“.fancybox”).fancybox();很多时候,这解决了问题。但我怎样才能防止这种情况再次发生呢。换句话说,我如何防止(如何知道)存在jQuery冲突。为什么所有的js文件都放在底部,这会提高文件的工作效率,还是放在顶部时不会工作?我在Youtube上看到了一个教程,这些文件放在上面。请始终使用一个版本的jquery。您使用了两个不同的版本。建议将所有Javascript放在页面底部,将所有css放在head部分。这样javascript就不会妨碍页面的显示。正如dom就绪或加载时通常需要的那样,获得许多thanx。在问题解决之后,我一直在努力理解如何使用jQuery并避免我遇到的问题,我还有几个问题要问。当我猜对的时候,ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js是jquery的主要版本,该版本与:code.jquery.com/jquery-latest.min.js冲突。有可能用另一个来代替这个吗?当我查看jQuery页面时,我看到了版本V.1.11和V2.1。当我说版本使用:ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js是版本V.1.11.js时,这是正确的吗?什么决定了使用哪个版本。当我想在js中使用其他元素时,我只需添加特定的js元素,如js/jquery.fancybox.pack.js?v=2.1.5对于fancybox,主js文件存储在ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js是v.1.11版。。是什么决定了js文件在底部的顺序,为什么要按这个顺序放置。最后,如果有任何书籍或视频可以帮助我理解jQuery,我会很高兴被告知。youtube上有很多内容,但没有人帮助我解决这个问题。Jquery自己的网站是一个非常好的学习场所。顺序很重要,因为fancybox需要jquery。
There is a jquery conflict, because of two jquery versions.
Add all your js file to the bottom and in the following order just before </body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="js/modernizr.js"></script> <!-- Modernizr -->
<script type="text/javascript" src="js/jquery.fancybox.pack.js?v=2.1.5"></script> <!-- fancybox -->
<script src="js/main.js"></script> <!-- Resource jQuery -->
<script type="text/javascript">
$(document).ready(function() {
$(".fancybox").fancybox();
});
</script>
Please remove all javascripts from the head section.
so your head section looks like :-
<head>
<title>Alternate Fixed And Scroll Backgrounds</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href='http://fonts.googleapis.com/css?family=Roboto:400,700,300' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="http://psteintj.home.xs4all.nl/css/reset.css"> <!-- CSS reset -->
<link rel="stylesheet" href="http://psteintj.home.xs4all.nl/css/style.css"> <!-- Resource style -->
<link rel="stylesheet" href="http://psteintj.home.xs4all.nl/css/jquery.fancybox.css?v=2.1.5" type="text/css" media="screen" /> <!-- fancybox -->
</head>