如何使用 Coffeescript 提取表格行的 ID?
HTML:
<tbody>
<tr id="66">
<td>Meeting</td>
<td>David Smith</td>
<td>10/02/2013</td>
<td>2.0</td>
<td><button class="add_button" type="button">Add</button></td>
</tr>
<tr id="75">
<td>Add to invoice</td>
<td>David Smith</td>
<td>10/22/2013</td>
<td>0.5</td>
<td><button class="add_button" type="button">Add</button></td>
</tr>
Coffeescript 尝试:
$(document).ready ->
$('.add_button').click ->
event = $(this).attr('id')
alert event
谢谢您的帮助!