-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
51 lines (43 loc) · 1.86 KB
/
index.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const main = document.getElementById("testimonials-section");
function getElements(callback){
fetch('data.json')
.then(response => response.json())
.then(data =>callback(data.testimonials))
}
getElements(data => {
data.forEach(element => {
let section = document.createElement("section");
section.classList.add("testimonial-container");
section.classList.add(element.studentName.toLowerCase().replace(/ /g, '-'))
let divInfo = document.createElement("div");
divInfo.classList.add("student-info")
let divText = document.createElement("div");
divText.classList.add("text");
divInfo.appendChild(divText);
let imageStudent = document.createElement("img");
imageStudent.src = element.studentImage;
imageStudent.alt = `${element.studentName}-image`;
let h1Name = document.createElement("h1");
h1Name.textContent = element.studentName;
let pRol = document.createElement("p");
pRol.classList.add("rol");
pRol.textContent = element.rol;
divInfo.appendChild(imageStudent);
divText.appendChild(h1Name);
divText.appendChild(pRol);
let pResume = document.createElement("p");
pResume.textContent = element.resume;
pResume.classList.add("resume");
let pTestimonial = document.createElement("p");
let qTestimonial = document.createElement("q");
qTestimonial.textContent = element.testimonial;
pTestimonial.appendChild(qTestimonial);
pTestimonial.classList.add("testimonial");
section.appendChild(divInfo)
section.appendChild(pResume);
section.appendChild(pTestimonial);
section.style.backgroundColor = element.color;
section.style.color = element.colorFont;
main.appendChild(section);
});
})