html
html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<div class="display">
<input type="number" class="text">
</div>
<div class="buttons">
<input type="button" value="1" class="btn">
<input type="button" value="2" class="btn">
<input type="button" value="3" class="btn">
</div>
<script>
const display = document.querySelector(".text"),
btns = document.querySelectorAll(".btn");
btns.forEach(function(btn) {
btn.addEventListener("click", buttons);
});
function buttons() {
display.value = this.value;
};
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
body {
}
Enter to Rename, Shift+Enter to Preview
js
js
1
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run