Why don't my alert message and background color change execute simultaneously?

后端 未结 3 857
一生所求
一生所求 2021-01-20 03:36

I\'m trying to get both my final Alert message \"Congratulations...\" and the HTML background color change to happen simultaneously. The color change happens after

3条回答
  •  [愿得一人]
    2021-01-20 04:04

    The next line of your javascript will not run until after the alert box has been dismissed. Instead of using an alert() you could use console.log() which would not pause execution.

    EDIT: My bad, you want the user to see it. As a commenter suggested below, simply change the background color before showing the alert().

提交回复
热议问题