JSFiddle - React, Tailwind, and code Playground
HTML
<table>
<thead>
<tr>
<th>Select</th>
<th>Name</th>
<th>Address</th>
<th>Phone</th>
</tr>
</thead>
<tbody>
<tr>
<td><button class="get-data">Select</button></td>
<td>Name1</td>
<td>Address1</td>
<td>Phone1</td>
</tr>
<tr>
<td><button class="get-data">Select</button></td>
<td>Name2</td>
<td>Address2</td>
<td>Phone2</td>
</tr>
</tbody>
</table>
<br />
<br />
<div id='temp-table'>
<button id='build-table'>Build a table</button>
</div>
JavaScript
$('.get-data').on('click', function(){
var $item = $(this).closest("tr").find('td');
$.each($item, function(key, value){
alert($(value).text());
})
});
$('#build-table').on('click', function(){
$('#temp-table').append('<table><thead><tr><th>Select</th><th>Name</th></tr></thead>' +
'<tbody><tr><td><button onclick="getData();return false">Select</button></td><td>Name1</td></tr>' +
'<tbody><tr><td><button onclick="getData();return false">Select</button></td><td>Name2</td></tr>' +
'</tbody></table>')
});
function getData() {
var $item = $(this).closest("tr").find('td');
$.each($item, function(key, value){
alert($(value).text());
})
}