<p>设置 y=5, 计算出 x=y-2, 并输出结果。</p> <button onclick="myFunction()">点我</button> <p id="demo"></p> <script> function myFunction() { var y=5; var x=y-2; var demoP=document.getElementById("demo"); demoP.innerHTML="x=" + x; } </script>