javascript - jQuery 类型错误 : $ is undefined

标签 javascript jquery html typeerror

我正在尝试使用 iCheck 插件,而且我是 JQuery 和 javaScript 的新手。我在浏览器中收到错误

TypeError: $ is undefined

我环顾四周,发现了这个 link ,但我尝试按照它的建议添加 (jQuery),但它没有更改错误消息。

我在网页上看到的症状是网页在复选框内没有悬停功能或黑色,例如 example北极星皮肤秀。

有什么想法吗?请参阅下面的“c 风格注释 -//”以了解 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>

最佳答案

您正在加载 <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>

关于javascript - jQuery 类型错误 : $ is undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23475405/

相关文章:

javascript - JQuery/Javascript 获取对象在对象数组中的位置

javascript - 如何让禁用的复选框在用户选择它时变为事件状态?

javascript等待php完成功能并刷新页面

jquery - 使用Jquery设置默认关闭的元素

javascript - 如何嵌入具有自定义样式的 xml 内容的 iframe?

html - 如何在区域 map 上赋予不透明度

javascript - 将值设置为输入 JQuery

javascript - 在api.js中传递参数

javascript - 使用 jquery 并行滚动文本区域和网页

html - 为什么我不能将 Logo 居中,这与格式有关吗?