Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/89.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 你能让它眨眼吗?_Javascript_Html_Caret - Fatal编程技术网

Javascript 你能让它眨眼吗?

Javascript 你能让它眨眼吗?,javascript,html,caret,Javascript,Html,Caret,我找到了这段代码,但我不知道如何使光标闪烁 var TxtType=函数(el、toRotate、句点){ this.toRotate=toRotate; this.el=el; this.loopNum=0; this.period=parseInt(period,10)| 2000; this.txt=“”; 这个。勾选(); this.isDeleting=false; }; TxtType.prototype.tick=函数(){ var i=this.loopNum%this.toR

我找到了这段代码,但我不知道如何使光标闪烁

var TxtType=函数(el、toRotate、句点){
this.toRotate=toRotate;
this.el=el;
this.loopNum=0;
this.period=parseInt(period,10)| 2000;
this.txt=“”;
这个。勾选();
this.isDeleting=false;
};
TxtType.prototype.tick=函数(){
var i=this.loopNum%this.toRotate.length;
var fullTxt=this.toRotate[i];
如果(这是删除){
this.txt=fullTxt.substring(0,this.txt.length-1);
}否则{
this.txt=fullTxt.substring(0,this.txt.length+1);
}
this.el.innerHTML=''+this.txt+'';
var=这个;
var delta=200-Math.random()*100;
如果(这是删除){
delta/=2;
}
如果(!this.isDeleting&&this.txt===fullTxt){
delta=这个周期;
this.isDeleting=true;
}else if(this.isDeleting&&this.txt==''){
this.isDeleting=false;
这个.loopNum++;
δ=500;
}
setTimeout(函数(){
那。勾选();
},三角洲);
};
window.onload=函数(){
var elements=document.getElementsByClassName('typewrite');
对于(var i=0;i.wrap{border right:0.05em solid#32CD32}”;
document.body.appendChild(css);
};

我找到了一个简单的方法,通过CSS右边框闪烁来实现

它每0.5s闪烁一次,但是,每次键入字母时,
都会被重建,因此CSS计时器会重置。当字母暂停键入并等待0.5秒以上时,您可以看到光标闪烁

var TxtType=函数(el、toRotate、句点){
this.toRotate=toRotate;
this.el=el;
this.loopNum=0;
this.period=parseInt(period,10)| 2000;
this.txt=“”;
这个。勾选();
this.isDeleting=false;
};
TxtType.prototype.tick=函数(){
var i=this.loopNum%this.toRotate.length;
var fullTxt=this.toRotate[i];
如果(这是删除){
this.txt=fullTxt.substring(0,this.txt.length-1);
}否则{
this.txt=fullTxt.substring(0,this.txt.length+1);
}
this.el.innerHTML=''+this.txt+'';
var=这个;
var delta=200-Math.random()*100;
如果(这是删除){
delta/=2;
}
如果(!this.isDeleting&&this.txt===fullTxt){
delta=这个周期;
this.isDeleting=true;
}else if(this.isDeleting&&this.txt==''){
this.isDeleting=false;
这个.loopNum++;
δ=500;
}
setTimeout(函数(){
那。勾选();
},三角洲);
};
window.onload=函数(){
var elements=document.getElementsByClassName('typewrite');
对于(var i=0;i
.typewrite>.wrap{
动画:闪烁。5s步结束无限交替;
右边框:实心3px#32CD32;
}
@关键帧闪烁{
50% {
边框颜色:透明;
}
}

你是否在谷歌文档中粘贴了一些代码,然后共享了文档并发布了公共链接,而不是仅仅在你的问题中粘贴代码?为什么?Jeremy Thille由于缩进相关的错误,平台一直阻止我发布它。我想不出问题出在哪里。我试着尽我所能把它缩进,但没有成功。我共享了一个txt文件,请删除所有包含代码块的注释。您可以编辑原始问题以添加代码。我为您做了这件事,并创建了一个代码片段。我想知道这是怎么发生的,谢谢。你也能让光标闪烁吗?我正在看。看起来,“光标”实际上是一个CSS
右边框:0.05em实心#32CD32
。一定有一个简单的方法让它闪烁使用CSS动画你是主谋,谢谢。你是如何学会编码的?多年来每天早上5点起床学习,犯下每一个可能的错误。。。如果我的回答解决了你的问题,别忘了把它标记为已接受:)无论如何,谢谢你,他们顺便把它关闭了,我不能把它标记为已解决