I have a problem with jQuery .
I'm going through a table of bootstrap with certain values, I need the values to be saved in an array, at this moment I'm going through the values separately, I do not know how I can go through all the values and save them in array
.
I would like it to be as follows:
valores = [modelo, codigo, precio, piezasporcaja, cantidaddepiezas]
This is what I have so far:
$("#ok").click(function() {
info = ""
$(".valores").parent("tr").find("td").each(function() {
info += $(this).text() + ",";
// info += this.value+ " ";
});
$('.valores').each(function(e) {
info += this.value + " ";
});
console.log(info);
alert(info);
})
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table class="table">
<thead class="thead-light">
<tr>
<th scope="col">Modelo</th>
<th scope="col">Codigo</th>
<th scope="col">Precio</th>
<th scope="col">Piezas por caja</th>
<th scope="col">Cantidad de Piezas</th>
</tr>
</thead>
<tbody>
<tr>
<th class='valores' scope="row">SILENT 100 DESIGN</th>
<td>5DESIGN100</td>
<td>$ 62.00 USD</td>
<td>4</td>
<td> <input type='number' class='form-control valores' name='qtyMulti' value='0' required min='0' max='99999'> </td>
</tr>
<tr>
<th class='valores' scope="row">SILENT 200 DESIGN</th>
<td>5DESIGN200</td>
<td>$ 85.00 USD</td>
<td>4</td>
<td> <input type='number' class='form-control valores' name='qtyMulti' value='0' required min='0' max='99999'> </td>
</tr>
</tbody>
</table>
<input type="button" value="ok" id="ok" class="boton2">