I have the following table shown below, I tried this
$("#tablaMultas tbody tr td:first-child")
but I cannot solve.
<table id="tablaMultas">
<thead>
<tr>
<th>Minuto inicial</th>
<th>Minuto linea</th>
<th>Minuto m. atras</th>
<th>Valor linea</th>
<th>Valor m. atras</th>
<th>Minuto Espera</th>
<th>Eliminar</th>
</tr>
</thead>
<tbody style="vertical-align: text-top;" id="cuerpoTablaMultas">
<tr id="filaMulta1" style="border-top: 1px solid #E1EEF4;">
<input type="hidden" name="valoresFila" value="1-0-0-0-0-1-5">
<td>1</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>5</td>
<td>
<p onclick="$("#filaMulta1").remove();">
<img src="../Maestros/imagenes/borrar.png">
</p>
</td>
</tr>
<tr id="filaMulta2" style="border-top: 1px solid #E1EEF4;">
<input type="hidden" name="valoresFila" value="2-0-0-0-0-1-5">
<td>2</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>5</td>
<td>
<p onclick="$("#filaMulta2").remove();">
<img src="../Maestros/imagenes/borrar.png">
</p>
</td>
</tr>
</tbody>
</table>
and I need create a array with the value from the firts of each , in this case it would be [1,2], somebody could help me, thanks in advance.
Try,
var values = $("#tablaMultas tbody").find("tr td:first-child").map(function(){
return $(this).text()
}).get();
Alert: Your html is completely invalid. Input tag cannot be a direct child of the tr
. Please refer the following demo to correct the mistake,
try
var text = $("#tablaMultas tbody tr td").map(function (i, val) {
if ($(this).index() == 1) {
return val.innerHTML
}
}).get();
console.log(text)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.