I have a table
<table> <tr class="PO1"></tr> <tr class="PO2"></tr> <tr class="PO3"></tr> </table>
How can I skip all tr ββwith class "PO1" and get the value of each value of 'td' ?
"PO1"
'td'
$("table#id tr .PO1").each(function(i) { // how to get the td values?? });
var values = $('table tr.PO1 td').map(function(_, td) { return $(td).text(); }).get();
This will create an array with the contents of the text from each td . It is probably best to use a map / object:
td
var values = $('table tr.PO1 td').map(function(index, td) { var ret = { }; ret[ index ] = $(td).text(); return ret; }).get();
The space in front of .P01 is a violation of your current code.
$("tr.PO1 td").each(function(i){ $(this).text() });
: I removed the space before .PO1 because your tr has class P01
$("table#id tr.PO1").each(function(i) { $(this).find("td").innerHTMl() //for example });
$("table#id tr.PO1").each(function(i) { i.children('td').each(function(tdEL) { // tdEl.val(); }); });
Pay attention to the space that I deleted between tr and .PO1. In this case, he will try to find each tr with a child having the class .PO1.