关于代码书写位置
<script type="text/javascript">
function count(){
var a = document.getElementById("txt1").value;
var b = document.getElementById("txt2").value;
var c = document.getElementById("select").value;
var result= "";
switch(c)
{
case"+":
result = parseFloat(a) + parseFloat(b);
break;
case"-":
result = parseInt(a) - parseInt(b);
break;
case"*":
result = parseFloat(a) * parseFloat(b);
break;
case"/":
result = parseInt(a) / parseInt(b);
break;
}
document.getElementById("fruit").value =result;
}
</script>
为什么上面这行代码 document.getElementById("fruit").value =result; 一定要放在以上那个位置才能运行成功,放在其他行就不行了呢,求解??????