javascript - Iterate through table rows with for loop -


i'm using jquery each loop loop through rows in table, if there row exists attribute data-prd-id hide it, did however, know loop run faster jquery.each. change, haven't had idea of how iterate through rows loop.

here 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 tried far loop didn't work:

var duplicatearr= {};     var objtest = $('#table-id > tbody > tr.tr1');     (var = 0; < 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;     } 

you try this

var trlist = $("#tableid > tbody ").children("tr");  for(var =0; i<trlist.length;i++){     console.log($(trlist[i])); } 

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - How to Hide Date Menu from Datepicker in yii2 -