forked from Keshav-0907/learnGit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
31 lines (25 loc) · 1.19 KB
/
script.js
File metadata and controls
31 lines (25 loc) · 1.19 KB
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
document.addEventListener('DOMContentLoaded', function() {
fetch('data.json')
.then(response => response.json())
.then(data => {
const studentList = document.getElementById('student-list');
data.forEach(student => {
const studentCard = document.createElement('div');
studentCard.className = 'student-card';
const name = document.createElement('div');
name.className = 'student-name';
name.textContent = `Name: ${student.name}`;
const email = document.createElement('div');
email.className = 'student-email';
email.textContent = `Email: ${student.email}`;
const year = document.createElement('div');
year.className = 'student-year';
year.textContent = `Year of Study: ${student.year_of_study}`;
studentCard.appendChild(name);
studentCard.appendChild(email);
studentCard.appendChild(year);
studentList.appendChild(studentCard);
});
})
.catch(error => console.error('Error fetching data:', error));
});