【发布时间】:2011-06-17 06:40:31
【问题描述】:
我的列表页面中有这样的代码:
<g:each in="${clientTripInstanceList}" status="i" var="clientTripInstance">
<tr class="${(i % 2) == 0 ? 'odd' : 'even'}" id="${(i % 2) == 0 ? 'odd' : 'even'}">
<td onclick="show_view('${clientTripInstance.id}')" class = "td_link">${fieldValue(bean: clientTripInstance, field: "number")}</td>
<td onclick="show_view('${clientTripInstance.id}')" class = "td_link">${fieldValue(bean: clientTripInstance, field: "client")}</td>
</tr>
</g:each>
现在
function show_view(trip_id){
var rowId = // get the id of the row
}
从这个函数我需要得到上面指定的表格行的 id。我如何使用 jQuery 获得它?我试过这个:
var rowId = (this).attr("id");
这根本不起作用。请注意,我在 <tr> 中定义了 id 而不是在 <td> 我正在调用该函数的地方,并且该函数在其他页面中定义。
【问题讨论】:
-
var rowId =$(this).attr("id");美元符号
标签: javascript jquery grails groovy