菜单切换
FACESOHO知行者
心灵
记录
远方
赞赏工具
源代码:
点击运行
保存
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>小鸟启蒙(facesoho.com)</title> </head> <body> <p>点击按钮 2 秒后输出 "Hello"。</p> <p>实例中,我们也会输出传递给 alertFunc() 函数的参数 (兼容所有浏览器)。</p> <button onclick="myStartFunction()">开始</button> <p id="demo"></p> <p id="demo2" style="color:red;"></p> <script> var myVar; function myStartFunction() { myVar = setTimeout(function(){ alertFunc("facesoho", "Google"); }, 2000); } function alertFunc(param1, param2) { document.getElementById("demo").innerHTML += "Hello "; document.getElementById("demo2").innerHTML = "传递给 alertFunc() 的参数:<br>" + param1 + "<br>" + param2 + "<br>"; } </script> </body> </html>
运行结果