Good afternoon, I have a table that is displayed for a list of objects (each object is 1 line).
<table id="criterionTable" class="table table-condensed table-hover table-responsive"> <thead class="table-head"> <tr> <th>name</th> <th>add</th> </tr> </thead> <tbody id="criteriaTableId"> </tbody> </table> function appendTableRows(data){ $.each(data, function(key, value){ $('#criterionTable > tbody:last-child').append("<tr>" + "<td>"+value.title+"</td>" + "<td><button class='addButton btn-primary btn-sm'><span class='glyphicon glyphicon-plus'></span></button></td>" + "</tr>"); }); }
I want that when I click on any of the buttons in the second column, I get the value corresponding to it from the first (name).
wrote such a script, but it does not work:
$('.addButton').click(function () { console.log($(this < 'tr:first').text()); });
Please tell me how to fix it. Thank.