wenzhixin bootstrap-table 点击table单元格改变颜色
生活随笔
收集整理的這篇文章主要介紹了
wenzhixin bootstrap-table 点击table单元格改变颜色
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
bootstrap-table用于展示數(shù)據(jù)非常方便,也需要滿足一些個(gè)性化需求。比如點(diǎn)擊窗格(td)標(biāo)記下顏色,用于目測(cè)
代碼如下,轉(zhuǎn)載請(qǐng)注明
$("table").on('click-row.bs.table', function (e, row, $el) {//el['0'] is tr $el is selected eleif ($el['0'].children[$el.context.cellIndex].className) {$el['0'].children[$el.context.cellIndex].className = '';} else {$el['0'].children[$el.context.cellIndex].className = 'success';}});解釋:
click-row.bs.table是行點(diǎn)擊事件,其實(shí)還有個(gè)click-cell.bs.table點(diǎn)擊窗格事件,但$el是string無法使用
$el是被點(diǎn)擊的行,$el.context是被點(diǎn)擊的窗格屬性。通過children尋找該行下那個(gè)被點(diǎn)的子元素td并添加樣式
轉(zhuǎn)載于:https://www.cnblogs.com/elsonwe/p/7121993.html
總結(jié)
以上是生活随笔為你收集整理的wenzhixin bootstrap-table 点击table单元格改变颜色的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: BZOJ 2045 容斥原理
- 下一篇: this的初步理解