W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <h1>JavaScript 确认框</h1> <button onclick="myFunction()">试一试</button> <p id="demo"></p> <script> function myFunction() { var txt; if (confirm("Press a button!")) { txt = "您按了确定"; } else { txt = "您按了取消"; } document.getElementById("demo").innerHTML = txt; } </script> </body> </html>