js 两个数相除

JavaScript019

js 两个数相除,第1张

function(a,b){

    var c = 0.00

    if(b != 0){

        c = (a/b).toFixed(2)

    }

    return c

}

<script type="text/javascript">

function G(e){return document.getElementById(e)}

</script>

单价:<input type="text" id="p" name="price" onkeyup="this.value=this.value.replace(/[^0-9\.]/g,'')" onblur="G('total').value = this.value / 0.9"/>

金额:<input type="text" id="total" name="total" />

输入完单价,点金额的输入框就好~~