Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/443.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用typed.js时遇到问题_Javascript_Html_Jquery_Typed.js - Fatal编程技术网

Javascript 使用typed.js时遇到问题

Javascript 使用typed.js时遇到问题,javascript,html,jquery,typed.js,Javascript,Html,Jquery,Typed.js,我最近尝试使用typed.js,但它不起作用。下面列出了html页面代码,如果有任何替代方法或任何其他方法可以获得类似效果,请与我分享或帮助我解决此问题 代码- <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script src="https://raw.github

我最近尝试使用typed.js,但它不起作用。下面列出了html页面代码,如果有任何替代方法或任何其他方法可以获得类似效果,请与我分享或帮助我解决此问题

代码-

<html>
<head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script src="https://raw.githubusercontent.com/mattboldt/typed.js/master/dist/typed.min.js"></script>


    <script>
        var heading = $(".typed");
        if(heading.length){
            heading.typed({
                strings: ["Startups", "Business", "Agencies"],
                // Optionally use an HTML element to grab strings from (must wrap each string in a <p>)
                stringsElement: null,
                typeSpeed: 100,
                startDelay: 500,
                backSpeed: 100,
                backDelay: 500,
                loop: true,
                showCursor: true,
                cursorChar: "|",
                attr: null,
                contentType: 'html',
                callback: function() {},
                preStringTyped: function() {},
                onStringTyped: function() {},
                resetCallback: function() {}
            });
        }
</script>
</head>
<body>
<h2>We are <span class="typed"></span> </h2>
</body>
</html>

变量标题=$(“.typed”);
if(标题、长度){
标题.键入({
字符串:[“初创企业”、“企业”、“机构”],
//可以选择使用HTML元素从中获取字符串(必须将每个字符串包装成)
stringsElement:null,
打字速度:100,
开始时间:500,
后退速度:100,
反向延迟:500,
循环:对,
是的,
cursorChar:“|”,
属性:空,
contentType:'html',
回调:函数(){},
PRESTRINGTYPE:函数(){},
onString类型:函数(){},
resetCallback:function(){}
});
}
我们是

您的代码有两个问题:您尝试导入typed.js的URL被破坏,并且您以错误的方式初始化typed。下面是一个工作示例:

var heading=$(“.typed”);
if(标题、长度){
var typed1=新类型('.Typed',{
字符串:[“初创企业”、“企业”、“机构”],
//可以选择使用HTML元素从中获取字符串(必须将每个字符串包装成)
stringsElement:null,
打字速度:100,
开始时间:500,
后退速度:100,
反向延迟:500,
循环:对,
是的,
cursorChar:“|”,
属性:空,
contentType:'html',
回调:函数(){},
PRESTRINGTYPE:函数(){},
onString类型:函数(){},
resetCallback:function(){}
});
}

我们是