简单教程
提交运行
代码编辑器:
<p id="demo">单击按钮来显示格式化的数字</p> <button onclick="myFunction()">点我</button> <script> function myFunction(){ var num = 15; var a = num.toString(); var b = num.toString(2); var c = num.toString(8); var d = num.toString(16); var n=a + "<br>" + b + "<br>" + c + "<br>" + d; var x = document.getElementById("demo"); x.innerHTML=n } </script>
运行结果: