0

サイトで jquery を使用するインスタンス (画像スライダーやナビゲーションなど) が複数ありますが、jquery 呼び出しを複数回行わないと機能しません。

たとえば、以下の 2 つのスニペットは、スクリプトを 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壊れた機能を復元します。

2 番目の 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 に答える