I have the following code
document.querySelector("#resultado").addEventListener("click",
function(event){
var id= $(this).find("tr").html();
alert(id);
}, false);
});
but I can not get the id. It is a product table and the first column is the idproduct. I work with MVC for what is created dynamically. After obtaining the id and the amount I will add it to a ticket detail but that later.
the html created from php is:
$arrayfiltrado=$P1->filtrar($tipoFiltro,$cadena);
$tabla ="<caption> CATALOGO DE ARTICULOS</caption>
<tr> <th>COD.:</th> <th>DESCRIPCION</th> <th>MARCA</th>
<th>CATEGORIA</th> <th>P/U</th>
</tr>";
/* No olvide el THEAD y sus TD para formar el encabezado de la tabla */
/* Contenido de la tabla */
$tabla .="<tbody>";
foreach ($arrayfiltrado as $p){
$tabla .="<tr>";
/* Un TD por cada datos que quieras mostrar; emj con el mail */
$tabla .="<td>".$p["idproducto"]."</td>";
$tabla .="<td>".$p["nombre"]."</td>";
$tabla .="<td>".$p["marca"]."</td>";
$tabla .="<td>".$p["categoria"]."</td>";
$tabla .="<td>".$p["precio"]."</td>";
$tabla .="</tr>";
}
$tabla .="</tbody>";
$tabla .="</table>";
echo $tabla;
}}