我有以下表结构:
<table id="currentloc_table">
<tr>
<th></th>
<th>Name</th>
<th>Details</th>
</tr>
<tr>
<td><input id='viewonMapCheckbox' type='checkbox'></td>
<td>
<span class="tooltip" href="#">
<span class="custom info">
<em>
</em>
Last Activity: 2013-03-12 03:29:21<br/>
Latitude: <span id="lat">30</span><br/>
Longitude: <span id="lon">70</span><br/>
</span>
</span>
</td>
<td>Details</td>
</tr>
</table>
我需要使用 Javascript 设置纬度和经度值,但无法使其工作。请帮帮我。这是我编写的代码:
var loc_table = document.getElementById('currentloc_table');
var loc_table_rows_count = document.getElementById('currentloc_table').getElementsByTagName("tr").length;
for (var i = 0; i < loc_table_rows_count; i++) {
if (i > 0) {//skipping header row
var row = loc_table.rows[i];
row.cells[1].firstChild.firstChild.getElementById("lat").innerHTML = "31";
row.cells[1].firstChild.firstChild.getElementById("lon").innerHTML = "71";
}
}