-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
29 lines (22 loc) · 1.1 KB
/
main.js
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
// tomar division
const conceptosDiv = document.getElementById('conceptos');
document.addEventListener("DOMContentLoaded", function () {
fetch('./conceptos.json')
.then((response) => response.json())
.then((json) => {
let data = json.conceptos;
let tabla = conceptosDiv.appendChild(document.createElement('table'));
document.createElement('h1').innerHTML = 'Conceptos';
// crear encabezados
tabla.appendChild(document.createElement('th')).innerHTML = 'Nombre';
tabla.appendChild(document.createElement('th')).innerHTML = 'Definición';
tabla.appendChild(document.createElement('th')).innerHTML = 'Cursos';
for (let i = 0; i < data.length; i++) {
// crear nueva fila
let fila = tabla.appendChild(document.createElement('tr'));
tabla.appendChild(document.createElement('td')).innerHTML = data[i].nombre;
tabla.appendChild(document.createElement('td')).innerHTML = data[i].definicion;
tabla.appendChild(document.createElement('td')).innerHTML += data[i].cursos;
}
})
});