Javascript 更改提交时按钮的颜色,直到输入新文本

Javascript 更改提交时按钮的颜色,直到输入新文本,javascript,Javascript,是否可以在提交按钮时更改按钮的颜色一段时间,直到整个过程再次开始?试试这个 document.getElementById('send_btn').style["background-color"]="red" setTimeout(function() { document.getElementById('send_btn').style["background-color"] = "" }, 1000) // 1000 - This value is in ms. (here time

是否可以在提交按钮时更改按钮的颜色一段时间,直到整个过程再次开始?

试试这个

document.getElementById('send_btn').style["background-color"]="red"
setTimeout(function() {
  document.getElementById('send_btn').style["background-color"] = ""
}, 1000) // 1000 - This value is in ms. (here time is 1second)

只需放置
element.style.backgroundColor=“color”在流程的不同步骤上。例如:

函数步骤(){
var按钮=document.getElementById(“btn”);
button.style.backgroundColor=“橙色”;
setTimeout(函数(){button.innerHTML=“1”;},1000);
setTimeout(function(){button.innerHTML=“2”;},2000);
setTimeout(函数(){button.innerHTML=“3”},3000);
setTimeout(函数(){button.style.backgroundColor=“番茄”},4000);
setTimeout(函数(){
button.innerHTML=“单击此处”;
button.style.backgroundColor=“天蓝”},6000);
}
按钮{
宽度:100px;
填充:15px;
背景:天蓝色;
}

单击此处
是的,这是可能的。你试过什么?这个过程是什么?我通常会在我希望它发生的函数中执行一些操作,例如“document.getElementById('send_btn').style.background color=“red“问题很自然地是,一旦它执行,它就会保持这种状态——甚至可以在函数上设置一个超时吗?您可以在任何函数中使用回调,您希望按钮在执行后更改颜色。或者,如果您只是想让它在一段时间后改变颜色,您可以使用