It turns out that I have this function
function showData(){
var valores = [];
$(this).parents("tr").find("td").each(function() {
valores.push($(this).text());
});
alert(valores);
}
which is supposed to show all the values of a selected row in a table, but it only shows me the alert without any values
the structure of my table, I bring it from a php file and it looks like this:
<table>
<tbody>
<tr>
<th></th>
</tr>
<tr>
<td></td>
</tr>
</tbody>
</table>
I know I'm doing something wrong by referring to the table and the td, but I do not know what it is, any help is welcome, thank you very much.
SOLVED
I have this function in which I receive the this that comes from the onclick of the button and I occupy it before .parents ().
function showData(show){
var valores = [];
$(show).parents("tr").find("td").each(function() {
valores.push($(this).text());
});
if(valores == null || valores == ""){
alert("valores vacios");
}else{
alert(valores);
}
}
and this is the button that comes from php
"<td><button class='btn btn-primary' onclick='showData(this)'> Click me</button></td>";
and this was what worked for me. Thank you very much to everyone who commented.