这段代码只是不想工作。我在警报窗口中收到的消息是 NaN
<script type="text/javascript">
var number1 = document.numbers.nr1.value
var number2 = document.numbers.nr2.value
function add(){
var total = number1 + number2;
return total;
}
</script>
<form action="" name="numbers">
<input type="text" name="nr1" />
<input type="text" name="nr2" />
<input type="submit" onclick="alert(add())" />
</form>