使用jQuery获取行的下一个节点的最快方法是什么?这是TreeList
生成的标记,它是GridView
asp.net的一种类型。我必须获得lblWorkItemId
199
。请考虑这是来自绑定控件。
<tr id="ctl00_PageContent_rtlRshItems_ctl04__2" class="rtlR rtlRL" style="background-color:Lavender;">
<td align="left" valign="middle" style="width:90px;">
<div id="ctl00_PageContent_rtlRshItems_ctl04_rcbStatut" class="RadComboBox RadComboBox_Windows7">
<table class="rcbFocused" style="border-width: 0pt; border-collapse: collapse;" summary="combobox">
<tbody>
<tr class="rcbReadOnly">
<td class="rcbInputCell rcbInputCellLeft" style="width:100%;">
<input id="ctl00_PageContent_rtlRshItems_ctl04_rcbStatut_Input" class="rcbInput" type="text" readonly="readonly" value="Submitted" name="ctl00$PageContent$rtlRshItems$ctl04$rcbStatut" autocomplete="off">
</td>
<td class="rcbArrowCell rcbArrowCellRight">
<a id="ctl00_PageContent_rtlRshItems_ctl04_rcbStatut_Arrow" style="overflow: hidden;display: block;position: relative;outline: none;">select</a>
</td>
</tr>
</tbody>
</table>
<input id="ctl00_PageContent_rtlRshItems_ctl04_rcbStatut_ClientState" type="hidden" name="ctl00_PageContent_rtlRshItems_ctl04_rcbStatut_ClientState" autocomplete="off">
</div>
</td>
<td class=" rtlCL" style="width:0px;">
<asp:label id="lblWorkItemId" text="199" visible="false"> </asp:label>
</td>
当组合框的选定值更改为某个值时,将调用以下javascript方法:
function OnClientSelectedIndexChanged(sender, eventArgs) {
var item = eventArgs.get_item();
if (item.get_text() == "Refused") {
var treeList = $find("<%= rtlRshItems.ClientID %>");
// var workItemId = [...]
OpenReasonWindow(workItemId);
}
}
答案 0 :(得分:2)
使用您的代码模板:
function OnClientSelectedIndexChanged(sender, eventArgs) {
var item = eventArgs.get_item();
if (item.get_text() == "Rejetée") {
var combo = $('input[id*="rcbStatut_Input"]')
var workItemId = combo.closest('tr.rtlRL').find('[id$="lblWorkItemId"]').attr('text');
OpenReasonWindow(workItemId);
}
}
注意:我通常会不引人注意地应用这种处理程序,而不是标记。