I have a java script to written to check the number of selected rows in a jquery data table. But the count doesn't works. Can anyone help in identifying the bug i made.
I may be silly please excuse and help me out.
var table = $("#jobsTable").dataTable();
$('#jobsTable tbody').on( 'click', 'tr', function () {
$(this).toggleClass('selected');
alert( table.rows('.selected').data().length +' row(s) selected' );
});
$('#batchAction').click( function () {
alert("button is clicked");
alert( table.rows('.selected').data().length +' row(s) selected' );
var selectedRows = table.rows('.selected').data().length ;
if( selectedRows === 0){
alert("Zero rows selected. Please select jobs to proceed with bulk Operation");
alert( table.rows('.selected').data().length +' row(s) selected' );
}
});