Javascript 如何使用json2html突出显示结果表的第行?

Javascript 如何使用json2html突出显示结果表的第行?,javascript,jquery,html,json,json2html,Javascript,Jquery,Html,Json,Json2html,我正在使用JSON2HTMLjQuery插件从JSON数据构建一个表, 以下是当前状态: 我想要的是在处理过程中比较currentID,这样就可以将“.active”添加到类中, 有什么建议吗 html <div class="container"> <p> <table id="placar" class="table table-condensed table-bordered"> <thea

我正在使用JSON2HTMLjQuery插件从JSON数据构建一个表, 以下是当前状态: 我想要的是在处理过程中比较currentID,这样就可以将“.active”添加到类中, 有什么建议吗

html

    <div class="container">
    <p>
        <table id="placar" class="table table-condensed  table-bordered">
            <thead>
                <tr>
                    <th>#</th>
                    <th>Luchador</th>
                    <th>K</th>
                    <th>D</th>
                    <th>Pontos</th>
                </tr>
            </thead>
            <tbody></tbody>
        </table>
</div>
通过标记#json2html进行搜索,找到了另一个让我找到解决方案的问题:

只要在class属性中添加一个函数来处理它,函数中的每一行数据都可以作为“this”使用

所以这个是这样的

class : function(){
        if( this.id == currentID ){
            return 'info';
        } else {
            return '';
        }
    },
完整的示例如下:

编辑

遗憾的是,json2html中的replace=true选项没有按预期工作。。。我编写了另一个解决方案,为每行添加id,并更新值。看看这里

class : function(){
        if( this.id == currentID ){
            return 'info';
        } else {
            return '';
        }
    },