如何检测单击了哪个删除按钮?

How detect which delete button was clicked?

我正在为我的网站使用 Semantic-UI。我有 table 数据,每一行都有删除按钮。单击按钮时,将显示模态。模态有两个按钮,取消或确认。当我单击确认时,我想从数据库中删除行。但是我如何检测点击了哪个按钮?

Table 在 HTML:

<tr>
   <td>Name</td>
   <td>      
      <button id='1' class="delete button"></button>
   </td>
</tr>
<tr>
   <td>Name2</td>
   <td>      
      <button id='2' class="delete button"></button>
   </td>
</tr>

当我单击 table 中的删除按钮时,会显示 javascript 模式。模态 Javascript

$('#removeAcredicationModal')
                .modal({
                    transition       : 'vertical flip',
                    mobileTransition : 'horizontal flip',
                    closable         : false,
                    approve          : '.submit, .approve',
                    deny             : '.cancel'
                    }
                })
                .modal('attach events', '.delete', 'show')
            ;

模态HTML

<div id="removeAcredicationModal" class="ui small modal">
   <div class="ui approve submit green labeled icon button">
      <i class="checkmark icon"></i>
      Delete
   </div>
   <div class="ui cancel red labeled icon button">
      <i class="remove icon"></i>
      Cancel
   </div>
</div>

点击确认按钮我想从数据库中删除项目

function doDelete(){
    var idOfRowToDelete = "??";
    //How to get the ID placed in table?
    //Using controller, etc...
};

知道如何在 toDelete 函数中从 table 获取 ID 吗??

使用e.target.id

$('button').click(function(e)
{
    alert(e.target.id);
   e.preventDefault(); 
});

http://jsfiddle.net/38h1ub4j/