wenzhixin bootstrap-table 根据data大小自动标红

需求是,有些数据低于标准时需要标红

思路:待table加载成功后,选取特定列,获取data判断并添加样式

代码如下,转载请注明

$('table').on('load-success.bs.table', function (data) {
        $("table tr td:nth-child(3)").each(function () {
            // $(this)['0'].className = 'success';
            if (parseInt($(this)['0'].innerText) < 100){
                $(this)['0'].className = 'danger';
            }
        });
    });

解释:

用jquery selector选择表的所有第三列,判断大小并添加样式

posted @ 2017-07-05 16:17  Els0n  阅读(472)  评论(0编辑  收藏  举报