0

我是 JS 新手。当用户在可编辑的数据表中单击它时,如何突出显示选定的行?

谢谢你。

4

1 回答 1

0

如果您使用的是 jquery 数据表插件,这里有一个示例:http: //datatables.net/release-datatables/examples/api/select_row.html

$(document).ready(function() {
    /* Add/remove class to a row when clicked on */
    $('#example tr').click( function() {
        $(this).toggleClass('row_selected');
    } );

    /* Init the table */
    var oTable = $('#example').dataTable( );
} );

/*
 * I don't actually use this here, but it is provided as it might be useful and demonstrates
 * getting the TR nodes from DataTables
 */
function fnGetSelected( oTableLocal )
{
    return oTableLocal.$('tr.row_selected');
}
于 2012-12-12T15:38:30.993 回答