比如有如下表格table:
<tr id="value_12">
<td>firstanme_1</td>
<td>lastname_1</td>
</tr>
<tr id="value_14">
<td>firstanme_2</td>
<td>lastname_2</td>
</tr>
用js获取的方法定义:
$('#table_id tr').each(function() {
var firstName = $("td", tr)[0].val()
var id = $(tr).attr('id').split("_")[1]
})
给tr一个id,然后获取//XX是id,string是获得的值
var row = document.getElementById('XX')
var string = row.innerHTML