2016-04-10 11 views
2

ボタンが送信されると、プロセス全体が再び開始されるまで一定の期間、ボタンの色を変更できますか?新しいテキストが入力されるまでサブミット時にボタンの色を変更する

+2

はい、それは可能です。何を試しましたか?どのようなプロセスですか? – smerny

+0

はい、間違いありません。 – Shomz

+0

私は通常、 "document.getElementById( 'send_btn')のようなことが起こるような場所で何かをやります。style.background-color =" red "これは一度実行すればこのようになります。関数にタイムアウトを設定することは可能ですか? – Alison1988

答えて

0

ちょうどプロセスの異なる段階に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>

0

この

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) 
関連する問題