<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<input type="text" id="radius" placeholder="请输入半径计算圆的面积!" />
<button type="button" onclick="circular()">计算</button>
<div id="msg">
</div>
<script>
function circular() {
let radius = document.getElementById("radius").value;
radius = parseInt(radius);
π = 3.14;
let s = π * radius * radius;
console.log(s);
document.getElementById("msg").innerHTML = s;
}
</script>
</body>
</html>
计算圆的面积
最新推荐文章于 2022-03-05 16:42:55 发布