<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
</head>
<script>
var sum = 0
function add(num,num2){
var f = num * 10 + num2
sum = f
document.write('<br>','<br>',f)
}
</script>
</body>
<input type='BUTTON' value = '1' onclick="add(sum,1)">
<input type="BUTTON" value="2" onclick="add(sum,2)">
<input type="BUTTON" value='3' onclick="add(sum, 3)">
<input type="BUTTON" value='4' onclick="add(sum, 4)">
<body>
</html>
I was making a calculator in JavaScript. I made it appended to the number displayed when the number button is pressed.
But'document.write' When outputting as a function, all the existing buttons disappeared. Is it possible to prevent the button from disappearing upon printing on the web page?