How to use javascript/jquery to loop through table? -


i have block of code below

<tbody class="society_list">     <tr>         <td>1</td>         <td>dummy</td>         <td>dummy</td>         <td id="lol0">update this</td>     </tr>     <tr>         .....     </tr> </tbody> 

what want loop through whole table, find td id, value of id, , update html inside. have now(sorry i'm quite new , still don't have idea do...)

function update(){   var trs = document.queryselectorall('.society_list tr');   for(i=0;i<trs.length-1;i++){     trs[i].find('td').each(function(){       //i know need here what's that..      });   } } 

iterate through tds have id attribute using has attribute selector.

$('.society_list tr td[id]').each(function(){   var tdid = $(this).attr('id'); // <--- getting id here   var result = dosomemagicwithid(tdid); // <--- doing   $(this).html(result);  // <---- updating html inside td }); 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -