2012-06-24 74 views
0

我正在嘗試使用jQuery和MooTools的基本網頁。jQuery/Mootools衝突錯誤

你可以在這裏看到一個工作示例:http://jsfiddle.net/DddQA/

但是,任何時候我嘗試引用MooTools的,它borks我的網頁。

這裏是我當前的代碼,我有問題有:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 

    <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"> 

     <head> 

     <script type="text/javascript" src="http://code.jquery.com/jquery-1.5.1rc1.min.js"></script>  
     <script type="text/javascript"> 
     <!-- remove this line below to make the hyperlink box work correctly --> 
     jQuery.noConflict(); 

     //<![CDATA[ 
     $(window).load(function(){ 
     $(".affiliate-scheme").click(function(){ 
      window.location=$(this).find("a").attr("href"); 
      return false; 
     }); 
     });//]]> 
     </script> 

     <!-- remove this line below to make the hyperlink box work correctly --> 
     <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/mootools/1.4.5/mootools-yui-compressed.js"></script> 

     </head> 

     <body id="affiliate-scheme"> 

      <div class="affiliate-scheme" style="background:red"> 
       <h3>Affiliate Scheme</h3> 
       <ul> 
        <li><a href="/affiliate-scheme/" title="Promote with our Affiliate Scheme">Promote Us</a></li> 
       </ul> 
      </div> 

     </body> 

    </html> 

非常感謝您的幫助這裏。非常感謝。

+1

使用'jQuery.noConflict();' – Dhiraj

+0

謝謝,DHIRAJ。你能解釋我如何在我的例子中使用它?我到目前爲止所嘗試的所有東西都沒有奏效:/謝謝。 – michaelmcgurk

+1

我知道你知道,但不要使用兩個不同的庫 - 選擇一個並使用它。 –

回答