I'm using jquery each loop to loop through rows in the table, if there is a row that already exists with the attribute data-prd-id then i will hide it, I successfully did it however, as I know the for loop run much faster than Jquery.each. I would like to change, but I haven't had any idea of how to iterate through rows with for loop.
Here is my code of Jquery.each
var duplicateArr= {};
$('#table-id > tbody > tr.tr1').each(function () {
var txt = $(this).attr('data-prd-id');
if (duplicateArr[txt] && txt != 0)
$(this).hide();
else
duplicateArr[txt] = true;
});
What i tried so far with for loop but it didn't work:
var duplicateArr= {};
var objTest = $('#table-id > tbody > tr.tr1');
for (var i = 0; i < objTest.length; i++) {
var txt = objTest.rows[i].attr('data-prd-id');
if (duplicateArr[txt] && txt != 0)
objTest.rows[i].hide();
else
duplicateArr[txt] = true;
}