I make a calculator on my website. But I encountered a problem. When the text is wider than the input width, the text is added correctly, but we can't see it. Note that when we do not press a button but enter it from the keyboard, it works, but I need to press them.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<!--CSS3-->
<style>
#result {
width: 100px;
height: 40px;
font-size: large;
}
</style>
<!--HTML5-->
<input type="text" id="result">
<button id="addSeven">7</button>
<button id="addEight">8</button>
<!--JavaScript-->
<script>
var result = document.getElementById("result");
var button7 = document.getElementById("addSeven");
var button8 = document.getElementById("addEight");
button7.onclick = function() {
result.value += "7";
}
button8.onclick = function() {
result.value += "8";
}
</script>
</body>
</html>