i have json stu which contain student name and department i have a html table that contains stuent name and department as header and table id as student i used each to add data in table but the datas are adding in one column empty on another column i am new to json can anyone hel
<!DOCTYPE html>
<html>
<head>
<title>JSON Demo</title>
<style>
table,th,td {
border: 1px solid black;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
<input type="button" onClick="StudentDetails()" value="Student Table" />
<div>
<table id="student">
<thead>
<tr>
<th>Student Name</th>
<th>Student Department</th>
</tr>
<thead>
<tbody></tbody>
</table>
</div>
<script>
function StudentDetails() {
var stu = [{
"stuname": "anbu",
"studep": "cs"
},
{
"stuname": "raj",
"studep": "Maths"
},
{
"stuname": "mani",
"studep": "science"
}
]
var table='<student>';
$.each(stu, function(i, item){
table+='<tr><td>'+item.stuname+'</td></tr>';
table+='<tr><td>'+item.studep+'</td></tr>';
});
$("#student").append(table);
console.log(table);
}
</script>
</body>
</html>