<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>十进制转换为二进制</title>
<script type="text/javascript">
var input_digit = 0;
var binary;
function digit_to_binary()
{
input_digit = document.getElementById('input_digit').value
binary = Number(input_digit).toString(2)
alert("转换的二进制结果为: " + binary)
}
</script>
</head>
<body>
<p>请输入一个合适的整数:
<input type="text" value="0" id="input_digit"/>
<input type="button" value="转换" onclick="digit_to_binary()" />
</p>
</body>
</html>
JavaScript ---- 示例(十进制转换为二进制)
最新推荐文章于 2024-10-30 19:10:39 发布