我正在尝试使用 Typed.js 库,但它似乎不起作用。它在控制台中给了我以下错误消息:
Uncaught TypeError: undefined is not a function
控制台中的参考是这一行:
$("#typed").typed({
该错误似乎表明我没有包含 jQuery,但我有。
<!-- TYPED -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="js/typed.js"></script>
<script>
$(function(){
$("#typed").typed({
strings: ["Typed.js is a <strong>jQuery</strong> plugin.", "It <em>types</em> out sentences.", "And then deletes them.", "Try it out!"],
typeSpeed: 30,
backDelay: 500,
loop: false,
contentType: 'html', // or text
// defaults to false for infinite loop
loopCount: false,
callback: function(){ foo(); },
resetCallback: function() { newTyped(); }
});
$(".reset").click(function(){
$("#typed").typed('reset');
});
});
function newTyped(){ /* A new typed object */ }
function foo(){ console.log("Callback"); }
的HTML:
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
<div class="post-heading">
<h1>Baresso og Starbucks</h1>
<h2 class="subheading element">Så mange kalorier smider de rundt</h2>
<h2 class="element" id="typed">hej</h2>
<span class="meta">Posted by <a href="https://www.linkedin.com/profile/view?id=176878997&trk=nav_responsive_tab_profile">Kristoffer Andreasen</a> on November 24, 2014</span>
</div>
这可能真的很简单,但我现在无法弄清楚。你能帮助我吗?