<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
</head>
<body>
<div style="text-align: center;">
输入售价后点击计算税费,自动显示在税费输入框!
</div>
<div class="item">
<div >售价:</div>
<div >
<input type="text" id="price" value=""/>
</div>
</div>
<div>
<div >税费:</div>
<div >
<input id="tax" type="text" autocomplete="off" value=""/>
<input type="button" id="calculate" value="计算税费" onclick="calculate()"/>
</div>
</div>
<script>
function calculate(){
/*获取输入的售价*/
var price = document.getElementById('price').value;
caltax = price*0.5;/*计算税费*/
var tax = document.getElementById('tax');/*获得tax*/
tax.value=caltax;/*把计算好的税费赋值到tax的value*/
}
</script>
</body>
</html>
效果图: