我正在尝试使用 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/