I want to get data from each row where the button is
$(document).ready(function() {
listar_predios();
function listar_predios() {
$.ajax({
type: 'ajax',
url: $host + 'predios/listar_predios',
asyn: true,
dataType: 'json',
success: function(data) {
var html = '';
var i;
for (i = 0; i < data.length; i++) {
html += '<tr id="predios">' +
'<td>' + data[i].clave_catastral + '</td>' +
'<td>' + data[i].productor + '</td>' +
'<td>' + data[i].uso_suelo + '</td>' +
'<td>' + data[i].clase_tierra + '</td>' +
'<td>' + data[i].cultivo1 + '</td>' +
'<td>' + data[i].cultivo2 + '</td>' +
'<input class="clave_catastral" type="hidden" value="' + data[i].clave_catastral + '">' +
'<td style="text-align:right;">' +
'<button class="btn btn-info btn-sm ver-mapa">VER EN MAPA</button>' +
'</td>' +
'</tr>';
}
$('#listado_predios').html(html);
$('#tabla_predios').DataTable({
responsive: true,
})
}
})
}
});
Here I consolo log the value from the input, but just works on first row
$(document).ready(function() {
$('#tabla_predios').on('click', 'button.ver-mapa', function() {
clave = $('.clave_catastral').val();
console.log(clave);
});