【发布时间】:2017-01-04 09:38:07
【问题描述】:
我想要在我的项目中做的是我有一个有两行的表。
第一行有 3 列,每个 td 中都有一个下拉列表。
第二行只有 1 列。
现在,我必须从下拉列表中获取具有特定选定值的 td 的 id。
我想做的是这样的:
$("#R1C1,#R1C2,#R1C3,#R2C1").append($("#selectServices"));
$(" #selectServices").on('change', function (){
if($("#selectServices option:selected" ).text()=="Check In"){
// need code to get td id from select dropdown with text as Check In
}
});
});
其中 R1C1 代表第 1 行第 1 列,依此类推..
selectServices 是我的下拉列表的 id
Check In 是我想要从下拉列表中选择的必填选项值
【问题讨论】:
-
1. ID 必须是唯一的 2. append 移动对象。您可能想要克隆它 - 请单击
<>以创建 minimal reproducible example