You can use the jquery filter function to apply a custom filter to the collection of objects returned by the selector, you can learn more about the filter here
Live demo
$("#datatable tbody tr").filter(function(){ if(arrIndexes.indexOf($(this).index()) != -1) return $(this); }).css('background-color', 'red');
source share