I have an html table:
<table class='headers'>
<tr>
<th>Gender</th>
<th>Height</th>
<th>Weight</th>
<th>Age</th>
<th>Occupation</th>
</tr>
<tr>
<td>Male</td>
<td>5'11</td>
<td>160</td>
<td>35</td>
<td>Doctor</td>
</tr>
</table>
If I had a JSON file with two more data sets, how can I parse them in Javascript so each new object creates a new tr?
jsonData = [
{
"Gender": "Female",
"Height": 5'2,
"Weight": 100,
"Age": 25,
"Occupation": "Lawyer"
},
{
"Gender": "Male",
"Height": 5'9,
"Weight": 150,
"Age": 23,
"Occupation": "Student"
}
]
I would need my new HTML to look like this:
<table class='headers'>
<tr>
<th>Gender</th>
<th>Height</th>
<th>Weight</th>
<th>Age</th>
<th>Occupation</th>
</tr>
<tr>
<td>Male</td>
<td>5'11</td>
<td>160</td>
<td>35</td>
<td>Doctor</td>
</tr>
</table>
<tr>
<td>Female</td>
<td>5'2</td>
<td>100</td>
<td>25</td>
<td>Lawyer</td>
</tr>
</table>
etc.
I've only parsed in Ruby before, and I had to 'require = json'' on the top of the file. Do I still have to do that?
Thanks!