[英]Selecting next SELECT in jQuery
$("select[id^='_taskAssignedTo_']").each(function(id) {
if ($(this).val() == "1") {
$(this).next().find("select[id^='_taskStatus_']").prop("disabled", false);
}
});
<td>
<select id="_taskAssignedTo_1"> <!-- options --> </select>
<td>
<td>
<select id="_taskStatus_1"> <!-- options --> </select>
<td>
我正在遍歷並找到第一個select
因為它具有我需要搜索的值,並且我想啟用它旁邊的select
,即_taskStatus_1
。 有很多,因此使用“開始於”語法非常重要。
上面的代碼不起作用。 我不確定是否需要使用next
, find
,其他方式或組合方式?
做就是了:
$(this).closest("td").next("td").find("select[id^='_taskStatus_']");
您必須先返回到td
(最近的位置),然后再返回到下一個td
(下一個),然后find
所需的元素。
嘗試:
$(this).parent().next().find("select[id^='_taskStatus_']").prop("disabled", false);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.