gpt4 book ai didi

javascript - 打字机效果不工作

转载 作者:行者123 更新时间:2023-11-28 16:25:40 27 4
gpt4 key购买 nike

每当我运行这段代码时,除了屏幕上的背景颜色,我什么也得不到。
typed.js 被下载并放在同一个文件夹中。出了什么问题?

 <!DOCTYPE html>
<html>
<head>
<title>type js</title>

<style type="text/css">
body{
margin: 0;
padding: 0;
background: #bf1f26;
}
.type{
color: black;
}
</style>

<script
src="https://code.jquery.com/jquery-3.2.1.js"> </script>

<script src="typed.js"></script>
<script type="text/javascript">
$(function(){
$(".type").typed({
strings: [
"Hello",
"My Name Is Aditya Aundhekar",
"I'm a Computer Engineer..",
],
})
})
</script>
</head>
<body>
<div class="center">
<span class="type"></span>
</div>
</body>
</html>

我收到这个错误:

jQuery.Deferred exception: $(...).typed is not a function TypeError: $(...).typed is not a function at HTMLDocument. (localhost/resume/typed.html:23:14) at mightThrow (code.jquery.com/jquery-3.2.1.js:3583:29) at process (code.jquery.com/jquery-3.2.1.js:3651:12) undefined jQuery.Deferred.exceptionHook @ jquery-3.2.1.js:3860 jquery-3.2.1.js:3869 Uncaught TypeError: $(...).typed is not a function at HTMLDocument. (typed.html:23) at mightThrow (jquery-3.2.1.js:3583) at process (jquery-3.2.1.js:3651)

最佳答案

你使用了错误的语法,试试这个代码:

 <!DOCTYPE html>
<html>
<head>
<title>type js</title>

<style type="text/css">
body{
margin: 0;
padding: 0;
background: #bf1f26;
}
.type{
color: black;
}
</style>

<script
src="https://code.jquery.com/jquery-3.2.1.js"> </script>

<script src="typed.js"></script>
<script type="text/javascript">
$(function(){
var options = {
strings: [
"Hello",
"My Name Is Aditya Aundhekar",
"I'm a Computer Engineer.."]
}

var typed = new Typed(".type", options);
})
</script>
</head>
<body>
<div class="center">
<span class="type"></span>
</div>
</body>
</html>

关于javascript - 打字机效果不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45245043/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com