2012-10-13 80 views
0

我想在同一頁上使用2個jQuery對象,但是,我似乎無法讓它們同時工作,如果我玩弄代碼,我可以得到一個或另一個工作但不是在同一時間。我對這個東西很新,所以非常感謝你的幫助。在同一頁上運行2個jQuery

在頭部分的代碼如下

<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.js"> 
</script> 


    <script src="jquery.easing.1.3.js" type="text/javascript"></script> 
    <script type="text/javascript"> 
     $(document).ready(function() { 

      $curtainopen = false; 

      $(".rope").click(function(){ 
       $(this).blur(); 
       if ($curtainopen == false){ 
        $(this).stop().animate({top: '0px' }, {queue:false, duration:350, easing:'easeOutBounce'}); 
        $(".leftcurtain").stop().animate({width:'60px'}, 2000); 
        $(".rightcurtain").stop().animate({width:'60px'},2000); 
        $curtainopen = true; 
       }else{ 
        $(this).stop().animate({top: '-40px' }, {queue:false, duration:350, easing:'easeOutBounce'}); 
        $(".leftcurtain").stop().animate({width:'50%'}, 2000); 
        $(".rightcurtain").stop().animate({width:'51%'}, 2000); 
        $curtainopen = false; 
       } 
       return false; 
      }); 

     }); 
    </script> 

回答

1

我認爲問題是,有衝突

jQuery的定義了一個很好的解決方案,以解決衝突:jQuery.noConflict。通過使用這個函數,你可以定義你自己的名字,在那裏可以訪問jQuery。

var $jq = jQuery.noConflict(true); 
+0

非常感謝您的回答,因爲我對這個新東西可以請您進一步解釋如何在我的代碼中使用此功能。 – AppleTattooGuy

+0

@JamesLeist您的非常歡迎...就像有整個文檔 –

+1

非常感謝您的幫助 - 完美的工作! :-) – AppleTattooGuy

相關問題