How do i highlighting rows and columns for multiple tables in same page?

How do i highlighting rows and columns for multiple tables in same page?

admail20admail20 Posts: 1Questions: 1Answers: 0
edited May 2014 in DataTables

Hello,

I'm new on jquery and datatables, I checked the example(https://datatables.net/examples/api/highlight.html) which is highlighting rows and columns for a single table, the example code shows to get a "table" instance, so I tried to use "each" to create datatables, but it sounds like the mouseover does not work as expected. the following is a example code I use:

$(document).ready(function() {
    var lastIdx = null;
    $('.exp').each(function () {
       var table=$(this).dataTable();
        $("tbody",this)
            .on('mouseover','td',function () {
                var colIdx=table.cell(this).index().column;
                alert(colIdx);
                if (colIdx !== lastIdx) {
                    $( table.cells().nodes() ).removeClass( 'highlight' );
                    $( table.column( colIdx ).nodes() ).addClass( 'highlight' );
                }
            })
            .on('mouseleave', function () {
                $( table.cells().nodes() ).removeClass( 'highlight' );
            });
    });
});

Could you help to check how can I use highlighting for multiple tables? Thanks very much.

This discussion has been closed.