-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
66 lines (55 loc) · 2.68 KB
/
index.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Calculeitor</title>
<link rel="stylesheet" href="estilos.css">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
</head>
<body>
<div class="container mt-4">
<div class="row">
<div class="col-md-6 offset-md-3">
<div class="Pantalla">
<input id="Resultado" readonly>
</div>
<div class="numeros mt-3">
<input id="Numero1" type="text" inputmode="numeric" pattern="[0-9]*" placeholder="Numero 1">
<input id="Numero2" type="text" inputmode="numeric" pattern="[0-9]*" placeholder="Numero 2">
</div>
<div class="btn-group mt-3" role="group" aria-label="Operaciones">
<button id="suma" type="button" class="btn btn-danger">Sumar</button>
<button id="resta" type="button" class="btn btn-danger">Restar</button>
<button id="multiplicacion" type="button" class="btn btn-danger">Multiplicar</button>
<button id="division" type="button" class="btn btn-danger">Dividir</button>
</div>
</div>
</div>
</div>
<script src="script.js"></script>
<script>
const numero1 = document.getElementById('Numero1');
const numero2 = document.getElementById('Numero2');
const resultado = document.getElementById('Resultado');
function calcular(operacion) {
const num1 = parseInt(numero1.value);
const num2 = parseInt(numero2.value);
resultado.value = operacion(num1, num2);
}
document.getElementById('suma').addEventListener('click', () => {
calcular(suma);
});
document.getElementById('resta').addEventListener('click', () => {
calcular(resta);
});
document.getElementById('multiplicacion').addEventListener('click', () => {
calcular(multiplicacion);
});
document.getElementById('division').addEventListener('click', () => {
calcular(division);
});
</script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
</body>
</html>