2014-05-05 48 views
6

我正在嘗試使用iCheck插件,我是JQuery和javaScript的新手。我發現了一個錯誤,說

TypeError: $ is undefined

我環顧四周,發現這link的瀏覽器,但我嘗試添加(jQuery的),因爲它暗示,但它並沒有改變錯誤消息。

我看到的網頁上的症狀是,該網頁沒有懸停工作或黑色內的複選框,如polaris皮膚節目example

任何想法?請參閱下面的「c-style comment - //」以瞭解TypeError指向的確切行。

這裏是從我的代碼的摘錄:

<html> 
    <head> 
     <title>jQuery Michele Project</title> 
     <link href="css/skins/polaris/polaris.css" rel="stylesheet"> 
     <link href="css/skins/all.css" rel="stylesheet"> 
     <link href="css/demo/css/custom.css" rel="stylesheet"> 
     <meta charset="UTF-8"> 
     <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
     <script src="js/icheck.js"></script> 
     <script type="text/javascript" src="js/jquery-1.11.0.js"></script> 
     <script type="text/javascript" src="js/jquery.ui.core.js"></script> 
     <script type="text/javascript" src="js/jquery.ui.widget.js"></script> 
     <script type="text/javascript" src="js/jquery.ui.accordion.js"></script> 
     <script type="text/javascript"> 
     $(document).ready(function(){ 
       $("#infolist").accordion({ 
        autoHeight: false 
       }); 
     }); 

     </script> 
     <script type="text/javascript"> 
      $(document).ready(function(){ 
       $('.input').iCheck({ 

        checkboxClass:'icheckbox_polaris', //this is the line that the error message points to 
        radioClass:'iradio_polaris', 
        increaseArea:'-10%' 
       }); 
      })(jQuery); 
     </script> 
     <style type="text/css"> 
      ul {list-style-type: none} 
      img {padding-right: 20px; float:left} 

      #infolist {width:500px} 
     </style> 
    </head> 
    <body> 
+3

您正在定義jQuery之前正在加載'''。首先加載jQuery。 – Dom

+0

[$是jQuery中未定義的錯誤]的可能重複(http://stackoverflow.com/questions/9313612/is-undefined-error-in-jquery) – JJJ

回答

10

您正在加載<script src="js/icheck.js"></script>定義的jQuery之前。首先加載jQuery。

<script type="text/javascript" src="js/jquery-1.11.0.js"></script> 
<script type="text/javascript" src="js/jquery.ui.core.js"></script> 
<script type="text/javascript" src="js/jquery.ui.widget.js"></script> 
<script type="text/javascript" src="js/jquery.ui.accordion.js"></script> 
<script src="js/icheck.js"></script> 
相關問題