This is my jQuery that mounts HTML in my cshtml.
$(data.resultado).each(function () {
str += '<tbody>';
str += '<tr>';
str += '<td>';
str += '<label style="font-size:10px"><a href="#">' + data.resultado[cont].CNPJ + '</a></label>';
str += '</td>';
str += '<td>';
str += '<label style="font-size:10px"><a href="#">' + data.resultado[cont].RazaoSocial + '</a></label>';
str += '</td>';
str += '</tr>';
str += '</tbody>';
cont++;
});
How do I do when clicking on a column (CNPJ or RazaSocial), it feeds one or another hidden field equivalent to the column.
So, I put the code passed to me and there is no alert when I click on the corresponding td. tblGrid is the name of my table. I did so and nothing on the alert
$('#tblGrid').on('click', 'td', function (e) {
var ancora = $(this).find('label a');
var valor = ancora.text();
alert(valor);
// e agora use o valor como quiser
});