简单教程
提交运行
代码编辑器:
<p id="p1">Hello World!</p> <script id="myScript" src="demo_async.js" async></script> <p>点击按钮检测是否异步执行脚本(一旦脚本可用)</p> <p id="demo"></p> <button onclick="myFunction()">尝试一下</button> <script> function myFunction(){ var x = document.getElementById("myScript").async; document.getElementById("demo").innerHTML = x; }; </script>
运行结果: