我最近问了一个关于这个的问题,我得到了使用以下代码将 jquery 代码分离到它们各自的库中的建议。
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
//code that uses 1.10.2 should be enclosed as follows right after loading 1.10.2
jQuery(function( $ ) {
//1.10.2 code goes here
});
</script>
<script src="js/jquery-1.4.4.min.js"></script>
<script>
//code that uses 1.4.4 should be enclosed as follows
jQuery(function( $ ) {
//1.4.4 code goes here
});
</script>
这适用于索引页面,但它似乎不适用于其他页面。我正在使用“Reveal Modal”和“magnific-popup”。我将它们都设置在各自的 jquery 库中,但是它们似乎仍然存在冲突。有问题的页面是mike-griffin.com/ronald_joyce.html。单击“我们的设计师”链接时会触发“显示模式”,并且单击页面上的图像时应触发“放大镜”灯箱,但它不会...但是如果我删除“ jquery-1.4 .4.min.js" 库可以正常触发,但“显示模式”停止工作。代码如下...
<script src="js/jquery-1.10.2.min.js"></script>
<script>
//code that uses 1.10.2 should be enclosed as follows right after loading 1.10.2
jQuery(function( $ ) {
$(document).ready(function() {
$('.image-link').magnificPopup({type:'image'});
});
$('.thumbnail-contaner').magnificPopup({
delegate: 'a', // child items selector, by clicking on it popup will open
type: 'image'
// other options
});
});
</script>
<script src="js/jquery-1.4.4.min.js"></script>
<script>
//code that uses 1.4.4 should be enclosed as follows
jQuery(function( $ ) {
$.backstretch("img/Background img/Zoe-10-Background.jpg" , {duration: 3000, fade: 1000});
$('#main-nav-modal').reveal({
animation: 'fadeAndPop', //fade, fadeAndPop, none
animationspeed: 300, //how fast animtions are
closeonbackgroundclick: true, //if you click background will modal close?
dismissmodalclass: 'close-reveal-modal' //the class of a button or element that will close an open modal
});
$('#sale-nav-modal').reveal({
animation: 'fadeAndPop', //fade, fadeAndPop, none
animationspeed: 300, //how fast animtions are
closeonbackgroundclick: true, //if you click background will modal close?
dismissmodalclass: 'close-reveal-modal' //the class of a button or element that will close an open modal
});
});
</script>
非常感谢您提供任何帮助,如果您读到这里但无济于事,我们将不胜感激。