JS编写华氏度转摄氏度
需要一个公式C=(F-32)*5/9。
没啥难度,练习题
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<script>
function change(){
var f=document.getElementById("f").value*1;
var c=(f-32)*5/9;
document.getElementById("c").value=c;
}
</script>
<style>
#button1{
border: 1px solid grey;
width:100px;
height: 50px;
font-size:20px;
font-family: "微软雅黑";
font-weight: bold;
}
#c{
border: 0.5px solid #5891FE;
border-radius: 5px;
width: 500px;
height: 40px;
font-size: 30px;
font-family: "微软雅黑";
}
#f{
border: 0.5px solid #5891FE;
border-radius: 5px;
width: 500px;
height: 40px;
font-size: 30px;
font-family: "微软雅黑";
}
.font1{
font-family: "微软雅黑";
font-size:40px;
</style>
<body><br><br><br><br><br><br><br>
<table width="100%" border="0">
<tbody>
<tr>
<td align="center"><font class="font1">华氏度转摄氏度</font></td>
</tr>
<tr>
<td align="center"><b class="font1">华氏度为:</b><input type="text" name="f" id="f"></td>
</tr>
<tr>
<td align="center"><b class="font1">摄氏度为:</b><input type="text" name="c" id="c"></td>
</tr>
<tr>
<td align="center"><input type="button" value="转换" id="button1" onClick="change()"></td>
</tr>
</tbody>
</table>
</body>
</html>