2010-12-21 141 views
1

我想爲jQuery(http://plugins.jquery.com/project/corners)使用圓角的演示,但是當它試圖運行時,我在Firefox和IE中都出現錯誤。jQuery插件沒有加載?

下面的代碼顯示了我想要做的,錯誤是'$(「。Section」)。角不是函數'。該頁面肯定會加載jquery,但不會加載角落插件。

任何人都知道爲什麼這會引發錯誤?

<script src="../../Content/Scripts/jquery-1.4.1.min.js" type="text/javascript"></script> 
<script src="../../Content/Scripts/jquery.corners.min.js" type="text/javascript"></script> 
<script type="text/javascript"> 
    $(document).ready(function() { 
     $('.Section').corners(); 
    }); 
</script> 
+0

你使用了哪些角落腳本? – Jordy 2010-12-21 15:50:00

+0

你能從你的瀏覽器訪問corners.js文件嗎? – PseudoNinja 2010-12-21 15:53:19

回答

1

我創建了一個頁面加載jQuery的角落,看看我是否能得到它在所有的工作:

<!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"> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <style type="text/css"> 
    .Section { 
     border-color: #000; 
     border-width: medium; 
     border-style: solid; 
    } 
    </style> 
    <script type="text/javascript" src="jquery-1.4.4.min.js"></script> 
    <script type="text/javascript" src="jquery.corners.min.js"></script> 
    <script type="text/javascript"> 
     $(document).ready(function() { 
      $('.Section').corners(); 
     }); 
    </script> 
    <title>Corners</title> 
    </head> 

    <body> 
    <p class="Section"> 
    Here is some text in my soon to be rounded corner paragraph. 
    </p> 
    </body> 
    </html> 

我在測試中發現那是什麼角落插件加載,但使用jQuery 1.4.4並使用Chrome 8.0.552.224,Safari 5.0.3,Firefox 3.6.13和Internet Explorer 8進行測試,只有Safari和Fireefox展示了角落。 Chrome在控制檯中產生了CSS錯誤,IE只是忽略了JavaScript。考慮到這一點,我建議你給CSS3 PIE a try for IE和使用一點連擊CSS爲您的其他元素:

<style type="text/css"> 
.Section { 
    -moz-border-radius: 20px; 
    -webkit-border-radius: 20px; 
    -khtml-border-radius: 20px; 
    border-radius: 20px; 
}  
</style> 

上面的CSS是一個例子產生in a blog post by Jon Raasch

5

在Firebug(或等效的開發人員工具)中使用Net面板並確保腳本首先被加載。如果沒有,您應該看到它在網絡面板中爲其訂單項返回404狀態。

+0

我得到了一個200角的腳本和jquery腳本 – DLeh 2010-12-21 16:20:11

-3

$('.Section').corner();$('.Section').corners()

,如果你使用「的jQuery插件一角」

2

我通過您的代碼運行,我看不出有什麼問題,這僅適用。你可以試試。就緒您的$(document)這裏面的代碼,看看它返回:

alert(typeof jQuery().corners) 

如果它會提醒「功能」,那麼你知道的角落加載。如果它警告「未定義」,那麼它不會加載,你可以追蹤到這個問題。

0

我使用相同的庫,並有同樣的問題,我做了什麼。

在您的document.ready代碼之前複製粘貼corner.js庫的整個代碼並檢查它是否開始工作?

if not not corner.js應該再次下載。