<!DOCTYPE html>
<
html
lang
=
"en"
>
<
head
>
<
meta
charset
=
"utf-8"
>
<
meta
name
=
"viewport"
content="
width
=
device
-width,
initial-scale
=
1
">
<
script
src="
</
script
>
</
head
>
<
body
>
<
center
>
<
h1
style
=
"color:green;"
>GeeksforGeeeks</
h1
>
<
h3
>Top 3 Students List</
h3
>
<
br
>
<
table
style
=
"border:10px;border-style: double;"
border
=
"2"
cellpadding
=
"20"
cellspacing
=
"20"
>
<
thead
>
<
tr
>
<
th
>NAME</
th
>
<
th
>ROLL NO</
th
>
<
th
>TOTAL MARK</
th
>
</
tr
>
</
thead
>
<
tbody
>
<
tr
>
<
td
align
=
"center"
data-stud
=
"student1"
data-topstud
=
"Name"
>
</
td
>
<
td
align
=
"center"
data-stud
=
"student1"
data-topstud
=
"Roll"
>
</
td
>
<
td
align
=
"center"
data-stud
=
"student1"
data-topstud
=
"TotalMark"
>
</
td
>
</
tr
>
<
tr
>
<
td
align
=
"center"
data-stud
=
"student2"
data-topstud
=
"Name"
>
</
td
>
<
td
align
=
"center"
data-stud
=
"student2"
data-topstud
=
"Roll"
>
</
td
>
<
td
align
=
"center"
data-stud
=
"student2"
data-topstud
=
"TotalMark"
>
</
td
>
</
tr
>
<
tr
>
<
td
align
=
"center"
data-stud
=
"student3"
data-topstud
=
"Name"
>
</
td
>
<
td
align
=
"center"
data-stud
=
"student3"
data-topstud
=
"Roll"
>
</
td
>
<
td
align
=
"center"
data-stud
=
"student3"
data-topstud
=
"TotalMark"
>
</
td
>
</
tr
>
</
tbody
>
<
tfoot
>
<
tr
>
<
th
>:</
th
>
<
th
> Top 3 Students List</
th
>
<
th
>:</
th
>
</
tr
>
</
tfoot
>
</
table
>
</
center
>
<
script
>
var data = {
"student1": [{
"Name": "Arun",
"Roll": 10056,
"TotalMark": 98,
}],
"student2": [{
"Name": "Vinoth",
"Roll": 10057,
"TotalMark": 96,
}],
"student3": [{
"Name": "Zafar",
"Roll": 10068,
"TotalMark": 85,
}]
}
//AJAX callback:
$('td').html(function() {
var $block = $(this)
return data[$block.data('stud')]
[0][$block.data('topstud')];
});
$("th").css("background-color", "#08f");
$("tr:nth-child(1)").css("background-color", "green");
$("tr:nth-child(2)").css("background-color", "yellow");
$("tr:nth-child(3)").css("background-color", "red");
</
script
>
</
body
>
</
html
>