2016-12-06 46 views

回答

3

問題是因爲confirm()調用阻止UI線程更新。一個解決辦法是放在一個setTimeout()confirm()電話用很短的延遲:

$(document).ready(function(){ 
    $("div").css("background-color", "red"); 
    setTimeout(function() { 
     confirm("Background not yet changed"); 
    }, 50); 
}); 

Updated fiddle

另一種方法是使用一種與模態替換confirm()箱庫,從而使任何時候UI都可以自由更新。

+0

謝謝,我會考慮這個。 – Sergey

+0

https://jsfiddle.net/9xa7pwvw/1/ 雖然需要更改處理。 – Sergey

相關問題