<p><span id="span1">Hello World!</span></p>

<script type="text/javascript">
document.getElementById('span1').style.background = 'red';
alert(1); alert(2); alert(3);
</script>

先弹出1,弹2,弹3,之后span才改变背景色。why?

alert会阻塞所有线程,而且alert会被优先执行。

参考:https://segmentfault.com/q/1010000006960660

 

相关文章:

  • 2021-05-28
  • 2021-12-04
  • 2021-09-12
  • 2022-01-06
  • 2021-08-13
猜你喜欢
  • 2022-12-23
  • 2021-07-10
  • 2022-12-23
  • 2022-12-23
  • 2021-07-31
  • 2021-04-14
相关资源
相似解决方案