<p id="demo">单击按钮给定与“2.5”最接近的整数</p> <button onclick="myFunction()">点我</button> <script> function myFunction(){ document.getElementById("demo").innerHTML=Math.round(2.5); } </script>