I'm getting a full table from my server side, I'm looking for td
with information that I want and saved this entire tr
in a variable like below:
var rowVoo;
$(table).find("tr td").each(function () {
if ($.trim($(this).text()) == "Porto Velho - RO") {
rowVoo = $(this).closest("tr");
}
});
The variable rowVoo
will look like this:
<tr>
<td>Porto Velho - RO</td>
<td>11</td>
<td>1 ( 9.1 %)</td>
<td>0 ( 0 %)</td>
<td>0 ( 0 %)</td>
</tr>
I have a list as an abbreviation:
<ul class="list-voos">
<li><span></span> VOOS PREVISTOS</li>
<li><span></span> ATRASADOS AGORA</li>
<li><span></span> VOOS CANCELADOS</li>
<li><span></span> ATRASADOS NO DIA</li>
</ul>
I need to pass the values that are within the td
to the span
that are within the list.
I search for the span
that are within the list:
var list = $(".list-voos").find("li").find("span");
And I try to iterate the values:
$(rowVoo).find("td").each(function () {
var that = $(this);
$(list).each(function () {
console.log($(this).text(that.text()));
return null;
});
});
But the values are duplicated and the span
of the list always gets the last value of td