-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
27 lines (24 loc) · 921 Bytes
/
script.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
document.addEventListener('DOMContentLoaded', () => {
const container = document.getElementById('container');
// Funkcja do pobierania danych z pliku JSON
async function fetchTexts() {
try {
const response = await fetch('text.json'); // Załaduj dane z pliku JSON
const texts = await response.json();
createSquares(texts);
} catch (error) {
console.error('Błąd podczas pobierania danych:', error);
}
}
// Funkcja do tworzenia kwadratów z tekstem
function createSquares(textArray) {
textArray.forEach(text => {
const square = document.createElement('div');
square.classList.add('square');
square.textContent = text;
container.appendChild(square);
});
}
// Wywołanie funkcji pobierającej dane z JSON
fetchTexts();
});