实例代码“Ctrl+/”提示“F11/ESC”全屏 返回 格式化 恢复 运行
x
 
1
<!DOCTYPE html>
2
<html>
3
<body>
4
5
<p>Click the button to display a confirm box.</p>
6
7
<button onclick="myFunction()">Try it</button>
8
9
<p id="demo"></p>
10
11
<script>
12
function myFunction()
13
{
14
var x;
15
var r=confirm("Press a button!");
16
if (r==true)
17
  {
18
  x="You pressed OK!";
19
  }
20
else
21
  {
22
  x="You pressed Cancel!";
23
  }
24
document.getElementById("demo").innerHTML=x;
25
}
26
</script>
27
28
</body>
29
</html>