How to get data-index of clicked button:
var removePair = $("button[name=removePair]"),
    tbody = $('tbody[name=tb-table]'),  
function DrawHtml(list) {
    var html = '';
    for (var i = 0; i < list.length; i++) {
        var o = list[i];
        html += '<tr name="row-' + i + '">';
        html += '   <td>';
        html += '       <button name="removePair" data-index="' + i + '" class="btn btn-primary mx-1" type="button"><i class="fa fa-trash-o" aria-hidden="true"></i></button>';
        html += '   </td>';
        html += '</tr>';
    }
    return html;
}
$(tbody).on("click", removePair, function () {
    console.log($(this));
    console.log($(this).val());
    console.log($(removePair));
});
The only way that I know to add event on dynamiclly added button is to attache it to parrent (tbody), and fire by dynamiclly created button removePair, but I dont know how to get clicked removePair for further logic.
this return tbody instead of removePair
thanks!!

on()method instead of elements. UseremovePair = "button[name=removePair]"var removePair = "button[name=removePair]", tbody = 'tbody[name=tb-table]';$(tbody).on("click", "button[name=removePair]", function () { console.log($(this)); });is working