在Javascript中设置文本动画

在Javascript中设置文本动画,javascript,html,css,animation,text,Javascript,Html,Css,Animation,Text,所以我的问题是,我想在你按enter键后在js中设置文本动画(不透明度),但我不知道如何使用我编写的代码。我无法解释为什么我不能制作动画,但我可以展示我所有的代码,你会理解的 函数句柄(e){ 如果(如keyCode===13){ e、 预防默认值(); 动作(); } } 函数睡眠(毫秒){ var start=new Date().getTime(); 对于(变量i=0;i毫秒){ 打破 } } } 功能滴定酶(str){ str=str.toLowerCase().split(“”);

所以我的问题是,我想在你按enter键后在js中设置文本动画(不透明度),但我不知道如何使用我编写的代码。我无法解释为什么我不能制作动画,但我可以展示我所有的代码,你会理解的

函数句柄(e){
如果(如keyCode===13){
e、 预防默认值();
动作();
}
}
函数睡眠(毫秒){
var start=new Date().getTime();
对于(变量i=0;i<1e7;i++){
如果((新日期().getTime()-start)>毫秒){
打破
}
}
}
功能滴定酶(str){
str=str.toLowerCase().split(“”);
对于(变量i=0;i=0;})){
if(输入包括(“HTTP:/”)| |输入包括(“HTTPS:/”){
window.location.href=inp.toLowerCase();
}
否则{
var ht=“http://”;
var loplink=高温混凝土(inp);
window.location.href=loplink;
}
}
else if(输入包括(“谷歌:”){
var googlesearch=inp.substr(7);
window.location.href=”https://www.google.fi/search?q=“+googlesearch.toLowerCase();
}
其他如果(输入包括(“DDG:)){
var ddgsearch=inp.substr(4);
window.location.href=”https://duckduckgo.com/?q=“+ddgsearch.toLowerCase();
}
else if(输入包括(“QWANT:”){
var qwantsearch=inp.substr(6);
window.location.href=”https://www.qwant.com/?l=en&h=1&hc=1&a=1&s=0&b=1&i=1&r=en&sr=en&q=“+qwantsearch.toLowerCase();
}
其他如果(输入包括(“HSL:”){
var hslsearch=inp.substr(4);
window.location.href=”https://m.reittiopas.fi/en/index.php?mod=ls&txtSearch=“+hslsearch.toLowerCase()+”&search=search”;
}
否则,如果(输入包括(“我的名字”)){
var nameis=inp.split(“IS”)[1];
var namelow=nameis.toLowerCase();
var namefcap=滴定酶(namelow);
var nameffinal=namefcap.split(“”).filter(函数(v){return v!=''});
如果(名称最终长度<3){
lop=“你好”+namefinal+“!我的名字是DAT Boiyiyiyiyi!”;
lop=lop.替换(“,”,”);
document.getElementById(“输出”).innerHTML=lop;
}
否则{
lop=“你有一个好名字!”;
document.getElementById(“输出”).innerHTML=lop;
睡眠(5000);
window.location.href=”http://www.zombo.com";
}	
}
其他如果(输入包括(“BG:”){
var=inp.substr(3);
document.getElementById(“theBodyOfAModel”).style.backgroundColor=BGGoods;
}
否则{
开关(inp){
案例“嘿”:
凯斯:“嘿!”
案例“嗨!”:
案例“嗨”:
案例“你好”:
案例“你好!”:
lop=“嘿!”;
打破
“嘿,SIRI!”:
案例“嘿,SIRI”:
案例“你好,SIRI”:
案例“嗨,SIRI!”:
案例“你好,SIRI”:
案例“你好,SIRI!”:
lop=“我不是Siri!我是dat Boiii!”;
打破
案例“FOO”:
lop=“Bar”;
打破
“酒吧”一案:
lop=“Foo”;
打破
案例“FOOBAR”:
“富吧”案:
lop='搜索名为“Foo”的酒吧';
打破
案例“现在几点了?”
案例“现在几点了”:
案例“现在几点了?”
案例“现在几点了?”
lop=“演示:”+Date();
打破
违约:
lop=“U WOT M8??”;
打破
}
document.getElementById(“输出”).innerHTML=lop;
}
}
函数stylejs(){
document.getElementById(“every”).style.width=“600px”;
document.getElementById(“每个”).style.borderColor=“蓝色”;
document.getElementById(“每个”).style.cursor=“自动”;
}
正文{
填充:0;
背景色:#ecf0f1;
}
#每一个{
字体大小:25px;
位置:绝对位置;
最高:50%;
左:50%;
右边距:0px;
页边距底部:0px:;
宽度:300px;
/*340px*/
高度:30px;
/*70像素*/
左边距:-173.4px;
利润率顶部:-38.08px;
填充:20px;
垂直对齐:中间对齐;
字体系列:“开放式Sans”,无衬线;
边框:1px实心#000;
边界半径:5px;
背景色:#fff;
颜色:#000;
-webkit过渡:宽度为0.4s,易于进出;
-moz过渡:宽度0.4s,易于输入输出;
-o型过渡:宽度为0.4s,易于进出;
过渡:宽度0.4s,易于进出;
}
#每个:悬停{
边框颜色:#2980b9;
背景色:#fff;
颜色:#000;
}
#每个人:焦点{
-webkit过渡:宽度为0.4s,易于进出;
-moz过渡:宽度0.4s e
function handle(e){
  if(e.keyCode === 13){
    e.preventDefault();

    //---- added code
    document.getElementById("output").style.opacity = 0;
    setTimeout(function(){
      theaction();
      document.getElementById("output").style.opacity = 1;
    },500);
    //----
  }
}