0
I have the following HTML code:
<div class="">
<table>
<tbody>
<tr>TITULO DO BOX</tr>
</tbody>
</table>
<table class="classeTable">
<tbody>
<tr>
<td>Esporte:</td>
<td>Futebol</td>
</tr>
<tr>
<td>Esporte:</td>
<td>Volei</td>
</tr>
<tr>
<td>Esporte:</td>
<td>Basquete</td>
</tr>
</tbody>
</table>
<div>
At the moment, I have several div
without identification and within these div
I have 2 table
, the first table
has the TITLE OF THE BOX and just that, already the second table
has the contents of the box but has a class
that can help, but this same class
is used in many other places, so it wouldn’t be used as an identifier, which could be used, would be the (TITLE OF THE BOX + class="classeTable"
), how could I gather this 2 information to identify exactly what I would like to take the values Football/Volleyball/Basketball?
A solution would be:
$(".classeTable > tbody > tr:nth-child(1) > td:nth-child(2)").text();
$(".classeTable > tbody > tr:nth-child(2) > td:nth-child(2)").text();
$(".classeTable > tbody > tr:nth-child(3) > td:nth-child(2)").text();
But as I mentioned earlier, this class="classeTable"
is being used in several places, so jQuery wouldn’t know for sure which class="classeTable"
choose.
Something like that would be ideal:
$("TITULO DO BOX .classeTable > tbody > tr:nth-child(1) > td:nth-child(2)").text();
$("TITULO DO BOX .classeTable > tbody > tr:nth-child(2) > td:nth-child(2)").text();
$("TITULO DO BOX .classeTable > tbody > tr:nth-child(3) > td:nth-child(2)").text();
But I don’t know exactly how to do this and if there’s any way to do it. Maybe there’s some other way that I don’t know.
It doesn’t make much sense. All right, you want to get the quoted texts within a given table that doesn’t have a unique identifier of its own, blz. The question I ask is: why do you want to take the text, for example, "football" from this table? What makes this table special? Then you could answer: "because you have the text 'football' that I want to catch"... Yes, but only this table has this text? If it’s just her, just loop the tables and see which one has the text "football". Simple like this.
– Sam
Just complementing, to select an element, something different from the others it must have, be it a letter that others do not have, a comma, a string.. finally, anything that can differentiate you from other brothers.
– Sam