jQuery TypeError:$是未定义的 [英] jQuery TypeError: $ is undefined

查看:129
本文介绍了jQuery TypeError:$是未定义的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用iCheck插件,而我是JQuery和javaScript的新手。我在浏览器中发现一个错误:


TypeError:$未定义


我环顾四周,发现这个链接 ,但我试图添加(jQuery),但它并没有改变错误信息。



我看到的网页上的症状是网页在复选框内没有悬停工作或黑色,例如 )。

有什么想法?请参阅下面的c-style comment - //以了解TypeError指向的确切行。



以下是我的代码摘录:

 < html> 
< head>
< title> jQuery Michele Project< / title>
< link href =css / skins / polaris / polaris.css =stylesheet>
< link href =css / skins / all.css =stylesheet>
< link href =css / demo / css / custom.css =stylesheet>
< meta charset =UTF-8>
< meta name =viewportcontent =width = device-width,initial-scale = 1.0>
< script src =js / icheck.js>< / script>
< script type =text / javascriptsrc =js / jquery-1.11.0.js>< / script>
< script type =text / javascriptsrc =js / jquery.ui.core.js>< / script>
< script type =text / javascriptsrc =js / jquery.ui.widget.js>< / script>
< script type =text / javascriptsrc =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',//这是行错误消息指向
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>


解决方案

您正在加载<脚本src =js / icheck.js>< / script> ,然后定义jQuery。首先加载jQuery。

 < script type =text / javascriptsrc =js / jquery-1.11.0.js >< /脚本> 
< script type =text / javascriptsrc =js / jquery.ui.core.js>< / script>
< script type =text / javascriptsrc =js / jquery.ui.widget.js>< / script>
< script type =text / javascriptsrc =js / jquery.ui.accordion.js>< / script>
< script src =js / icheck.js>< / script>


I'm trying to use the iCheck plugin and I'm new to JQuery and javaScript. I'm getting an error in the browser that says

TypeError: $ is undefined

I looked around and found this link, but I tried adding (jQuery) as it suggests, but it didn't change the error message.

The symptom on the web page that I see is that the web page doesn't have hover working or black inside the checkbox, like the example for polaris skin shows.

Any ideas? See the " c-style comment - //" below to know the exact line that the TypeError is pointing to.

Here is an excerpt from my code:

<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>

解决方案

You are loading <script src="js/icheck.js"></script> before jQuery is defined. Load jQuery first.

<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>

这篇关于jQuery TypeError:$是未定义的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆