forked from geetanshu-m/JKLU-Celebrates-Hacktoberfest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
55 lines (50 loc) · 1.55 KB
/
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
function readTextFile(file)
{
var rawFile = new XMLHttpRequest();
rawFile.open("GET", file, false);
rawFile.onreadystatechange = function ()
{
if(rawFile.readyState === 4)
{
if(rawFile.status === 200 || rawFile.status == 0)
{
var allText = rawFile.responseText;
alert(allText);
}
}
}
rawFile.send(null);
}
function add_elements(){
let data = [
{
"name":"Geetanshu Mathur",
"branch":"Computer Science and Engineering (VII Semester)",
"year" : "2015"
},
{
"name":"Sharthak Vijayvergiya",
"branch":"Computer Science and Engineering (VII Semester)",
"year":"2015"
},
]
par = document.getElementById("participants")
data.forEach(element => {
var student = document.createElement("div");
student.className = "student"
var name = document.createElement("div");
name.className = "name";
name.appendChild(document.createTextNode(element.name));
var branch = document.createElement("div");
branch.className = "branch";
branch.appendChild(document.createTextNode(element.branch));
var year = document.createElement("div");
year.className = "year";
year.appendChild(document.createTextNode(element.year));
student.appendChild(name);
student.appendChild(branch);
student.appendChild(year);
par.appendChild(student);
});
}
add_elements()