<html>
<body>
<p>单击按钮可显示 PI 和 2*PI 的余弦值。</p>
<button onclick="myFunction()">试一试</button>
<p id="demo"></p>
<script>
function myFunction() {
var a = Math.cos(Math.PI);
var b = Math.cos(2 * Math.PI);
document.getElementById("demo").innerHTML = a + "<br>" + b;
}
</script>
</body>
</html>