bootstrap table 獲取行點(diǎn)擊事件onClickRow,并獲得所點(diǎn)擊的row,然后調(diào)用alert顯示所點(diǎn)擊行的id
認(rèn)證高級(jí)PHP講師
這個(gè)可以用jQuery獲取你點(diǎn)擊的是第幾個(gè)tr,假設(shè)是i,然后你想獲取id,應(yīng)該把tr的id設(shè)置為你想獲取的那個(gè)id,當(dāng)你點(diǎn)擊獲取了i之后就可以獲取第i個(gè)tr的id了
因?yàn)槟銢]有貼相應(yīng)的代碼,所以我也就不貼代碼了。。。不懂可以追問
<table>
<thead>
<tr onclick="clickRowByInline(this)">
<th>1</th>
<th>2</th>
<th>3</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
</tbody>
</table>
<script src="http://cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>
<script>
function clickRowByInline(e) {
console.log(e);
}
$('tbody tr').on('click', clickRow);
function clickRow(ev) {
console.log(ev.currentTarget);
}
</script>