I was able to dynamically generate a table with some hidden fields that may not appear. But I'm having trouble fetching these fields and then sending them to a post. Here is the generated html code.
<tr>
<td>Tenis Azul</td>
<td>35</td>
<td>99.99</td>
<td>Admin</td>
<td><input type="checkbox" value="true"></td>
<td><a class="botao-remover btn btn-danger glyphicon glyphicon-trash" href="#"></a></td>
<input type="hidden" value="1">
<input type="hidden" value="35">
<input type="hidden" value="99.99">
<input type="hidden" value="1">
<input type="hidden" value="1">
</tr>
I have several generated like this. But at the time of selecting the values I do not know how to fetch to store in variables. I've already tried .attr ("value"). Val () but not right.
var linhas = $("tbody>tr");
linhas.each(function(){
var id_produto = $(this).find("input:nth-child(1)").attr("value").val();
console.log(id_produto);
});
Error:
Uncaught TypeError: $(...).find(...).attr(...).val is not a function
Can anyone help me? Thank you in advance