编辑下面的代码:【加编码】
<html> <body> <p>Click the button to display a confirm box.</p> <button onclick="myFunction()">Try it</button> <p id="demo"></p> <script> function myFunction() { var x; var r=confirm("Press a button!"); if (r==true) { x="You pressed OK!"; } else { x="You pressed Cancel!"; } document.getElementById("demo").innerHTML=x; } </script> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂