I am relatively new to javascript and I created a function to multiply two numbers together, but document.write
replaces the whole page with the answer. I know this is what document.write
is supposed to do, but just wanted an alternative. Remember, I am new to the language, so if it's possible, try to explain the answer. Thanks!
<script language="javascript">
function calculate(){
var number1= document.getElementById("num1");
var number2= document.getElementById("num2");
var answer=number1.value * number2.value;
document.write(answer);
}
</script>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…