这是我正在构建的简单货币转换器的一些代码。脚本运行良好,calculate()
但clear()
代码拒绝工作,而且看起来一样??
<a href="#" OnCLick="calculate();">US - CDN</a>
<a href="#" OnCLick="clear();">Clear</a>
<script type="text/javascript">
function clear() {
document.getElementById('us-cdn1').innerHTML = '';
}
</script>
<script type="text/javascript">
function calculate() {
var amount = parseFloat(document.getElementById("amount").value);
var result = document.getElementById("amount");
result.value = (amount).toFixed(2);
var result = document.getElementById("amount1");
result.value = (amount * .9861932938856016).toFixed(2);
document.getElementById('us-cdn').innerHTML = 'US';
document.getElementById('us-cdn1').innerHTML = 'CDN';
}
</script>