繁体   English   中英

TypeError:undefined不是函数(评估'$(“#typed”)。typed')

[英]TypeError: undefined is not a function (evaluating '$(“#typed”).typed')

我正在使用插件Typed.js初始化函数时,出现上述错误。 它表明jQuery没有在插件之前加载,但我不明白为什么。

HTML

<script type="text/javascript" src="jquery-2.1.3.min.js"></script>
<script type="text/javascript" src="typed.js"></script>

在标题中。

<script>
function type(){

$("#type").typed({
    strings: ["^1000to the biggest student organised fest in Kanpur", "to the biggest student organised fest in UP", "to the biggest student organised fest in <span style='color: #ffee00'>India</span> ^800."],
            typeSpeed: 10,
            stringstops: [41, 41, 41],
            backDelay: 600,
            showCursor: true,
            loop: false,
            contentType: 'html', // or text
            // defaults to false for infinite loop
            loopCount: false,
});
}

window.onload=type;
</script>

在身体的尽头。

有人能找到错误吗?

检查您的代码,重复的<script src="js/jquery-2.2.3.min.js"></script>等于不包括jQuery

删除重复的...

如果未加载jQuery,则会在$上引发引用错误。

它说.typed是未定义的,所以:

  1. 您指向src="typed.js" URL未返回脚本
  2. 该脚本没有为jQuery对象提供typed属性

假设我找到了正确的脚本,那肯定不是选项2: http//jsfiddle.net/1gap1b39/

检查开发人员工具的“网络”选项卡,以确保脚本得到200 OK响应。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM