[英]Changing a buttons colour on submit until new text is entered
是否可以在提交按钮后一段时间内更改按钮的颜色,直到整个过程再次开始?
尝试这个
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";
在过程的不同步骤上。 例:
function steps() { var button = document.getElementById("btn"); button.style.backgroundColor = "orange"; setTimeout(function(){ button.innerHTML = "1"; }, 1000); setTimeout(function(){ button.innerHTML = "2"; }, 2000); setTimeout(function(){ button.innerHTML = "3"; }, 3000); setTimeout(function(){ button.style.backgroundColor = "tomato"; }, 4000); setTimeout(function(){ button.innerHTML = "click here"; button.style.backgroundColor = "skyblue"; }, 6000); }
button { width: 100px; padding: 15px; background: skyblue; }
<button id=btn onclick="steps()">click here</button>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.