0

我有多个在我的网站上使用 jquery 的实例(如图像滑块和导航),但如果我不多次调用 jquery,它们将不起作用。

例如,除非我两次调用脚本,否则下面的 2 个片段将不起作用。请帮忙。(我的页面上有更多的 jquery 调用以及调用不同的库)我不能只调用最新的库一次并完成它吗?我试过了,还是不行。

<!--menu -->
<script type="text/javascript" src="js/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/newnav.css" />
<script type="text/javascript" src="js/navdoublecolumn.js"></script>
<script>
<!--
ddmegamenu.docinit({
    menuid:'solidmenu',
    dur:0, 
    easing:'easeInOutCirc' //<--no comma after last setting
})
// -->
</script>



<!-- slide -->
<script type="text/javascript" src="js/jquery.min.js"></script>
<script src="js/jquery.tabSlideOut.v1.3.js"></script>

<script type="text/javascript">
$(function(){
    $('.slideout1').tabSlideOut({
        tabHandle: '.slideouthandle1',             //class of the element that will become your tab
        pathToTabImage: 'images/slideouttab_chat.jpg',//path to the image for the tab //Optionally can be set using css
        imageHeight: '150px',                     //height of tab image           //Optionally can be set using css
        imageWidth: '40px',                       //width of tab image            //Optionally can be set using css
        tabLocation: 'left',                      //side of screen where tab lives, top, right, bottom, or left
        speed: 200,                               //speed of animation
        action: 'click',                          //options: 'click' or 'hover', action to trigger animation
        topPos: '215px',                          //position from the top/ use if tabLocation is left or right
        leftPos: '20px',                          //position from left/ use if tabLocation is bottom or top
        fixedPosition: true                       //options: true makes it stick(fixed position) on scroll
    });

});
</script>
4

2 回答 2

1

我预计其中的某些navdoublecolumn.js内容会覆盖或以其他方式破坏 jQuery 功能。通过第二次包含 jQuery,您正在重新定义方法/变量,从而恢复navdoublecolumn.js已损坏的功能。

通过查看删除第二个 jQuery 包含时得到的 javascript 控制台错误输出,您可能会了解发生了什么问题。

于 2013-01-25T09:41:32.633 回答
0

当你jQuery.noconflict()使用这个:

jQuery(function($){
    $('.slideout1').tabSlideOut({
        tabHandle: '.slideouthandle1',             //class of the element that will become your tab
        pathToTabImage: 'images/slideouttab_chat.jpg',//path to the image for the tab //Optionally can be set using css
        imageHeight: '150px',                     //height of tab image           //Optionally can be set using css
        imageWidth: '40px',                       //width of tab image            //Optionally can be set using css
        tabLocation: 'left',                      //side of screen where tab lives, top, right, bottom, or left
        speed: 200,                               //speed of animation
        action: 'click',                          //options: 'click' or 'hover', action to trigger animation
        topPos: '215px',                          //position from the top/ use if tabLocation is left or right
        leftPos: '20px',                          //position from left/ use if tabLocation is bottom or top
        fixedPosition: true                       //options: true makes it stick(fixed position) on scroll
    });

});
于 2013-01-25T11:23:21.713 回答