编辑下面的代码:【加编码】
<html> <body> <p>点击按钮查看输入的对话框。</p> <button onclick="myFunction()">点我</button> <p id="demo"></p> <script> function myFunction() { var x; var person=prompt("请输入你的名字","Harry Potter"); if (person!=null) { x="你好 " + person + "! 今天感觉如何?"; document.getElementById("demo").innerHTML=x; } } </script> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂