蒲式耳,磅换算成公斤和吨

一个小东西,给自己留作备份用的

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>蒲式耳, 磅 换算成公斤和吨</title>

    <style>
        #box1{ margin-bottom: 50px; }
        .des{ font-size: 13px; color: #666; margin: 10px 0;}

    </style>
</head>
<body>
    <div id="box1">
        <input type="text" placeholder="请输入蒲式耳" id="txt">
        <button id="btn">蒲式耳转化为千克和吨</button>
        <div class="des">
            1蒲式耳 = 27.216公斤
        </div>
        <div id="content"></div>
    </div>

    <div>
        <input type="text" placeholder="请输入磅" id="txt2">
        <button id="btn2">磅转化为千克和吨</button>
        <div class="des">
            1磅 = 0.45359237公斤
        </div>
        <div id="content2"></div>
    </div>
    <script>
        window.onload = function () {
            let btn = document.getElementById(btn)
            let txt = document.getElementById(txt)
            let content = document.getElementById(content)

            btn.onclick = function() {
                let num = txt.value * 27.216
                content.innerHTML = txt.value + 蒲式耳 +  =  + num + 公斤 +  =  + num * 2 +  +  =  + num / 1000 + 
            }

            let btn2 = document.getElementById(btn2)
            let txt2 = document.getElementById(txt2)
            let content2 = document.getElementById(content2)

            btn2.onclick = function() {
                let num = txt2.value * 0.45359237
                content2.innerHTML = txt2.value +  +  =  + num + 公斤 +  =  + num * 2 +  +  =  + num / 1000 + 
            }
        }
    </script>
</body>
</html>

 

蒲式耳,磅换算成公斤和吨

上一篇:压缩代码加速ecshop程序页面加载速度


下一篇:分享一个快速设置背景的js 自动获取背景图的长宽