wenzhixin bootstrap-table 点击table单元格改变颜色
bootstrap-table用于展示数据非常方便,也需要满足一些个性化需求。比如点击窗格(td)标记下颜色,用于目测
代码如下,转载请注明
$("table").on('click-row.bs.table', function (e, row, $el) { //el['0'] is tr $el is selected ele if ($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是行点击事件,其实还有个click-cell.bs.table点击窗格事件,但$el是string无法使用
$el是被点击的行,$el.context是被点击的窗格属性。通过children寻找该行下那个被点的子元素td并添加样式
sort of, I have some experience in the domain of database(MySQL/mongo), java, python, front-end, etc. I'll willing to give and accept bits of help from others.
now base in Singapore.