forked from ashish11chawda/Octoweek
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
28 lines (26 loc) · 812 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
28
let xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
let res = JSON.parse(xhttp.responseText);
showcard(res);
}
};
xhttp.open("GET", "list.json", true);
xhttp.send();
const container = document.querySelector("#container");
function showcard(list) {
const maleImg = "./man.png";
const femaleImg = "./woman.png";
list.map((obj) => {
let card = document.createElement("div");
card.classList.add("card");
card.innerHTML = `
<div class="inner">
<img src="${obj.gender == "male"? maleImg : femaleImg}" alt="${obj.gender}">
${obj.name}<br/><br/>
${obj.semester} Semester, ${obj.branch}
</div>
`;
container.appendChild(card);
});
}