【发布时间】:2012-04-01 07:08:36
【问题描述】:
我有一个 3x3 的 td 表,每个表都有 id (id='a1'...id='c3')。我希望能够点击 9 个 td 中的任何一个并提醒该 td 的 id。
这是我的 Coffeescript(在资产管道中)
$(document).ready ->
$("td").click ->
alert(#I would like to alert the id of whichever of the 9 td cell's have been clicked on)
这是我的 index.html.erb
<table>
<tbody>
<tr>
<td id='a1'>A1</td>
<td id='b1'>B1</td>
<td id='c1'>C1</td>
</tr>
<tr>
<td id='a2'>A2</td>
<td id='b2'>B2</td>
<td id='c2'>C2</td>
</tr>
<tr>
<td id='a3'>A3</td>
<td id='b3'>B3</td>
<td id='c3'>C3</td>
</tr>
</tbody>
</table>
我在 JS 方面很糟糕,所以感谢任何帮助!
【问题讨论】:
标签: javascript html ruby-on-rails-3 jquery-ui coffeescript