<div>
<input id="abc_lkid" type="hidden" value="001i0000008MQKP" >
<input id="abc_lkpld" type="hidden" value="001i00000022222P" >
<select id="selectedAccountId" class="accSelectandlookup" style="width:250px" size="1" >
<option value="000000000000000000">Create New Account: Pradys</option>
<option value="111111111111111111">Attach to Existing : Ace Iron and Steel Inc.</option>
</select>
</div>
我需要获取持有选择的div中ID以lkid结尾的最近隐藏字段的值
最佳答案
您可以使用attribute ends with selector:
$('#selectedAccountId').siblings('input[type="hidden"][id$="lkid"]').val();
获取相对于
id
的lkid
以select
结尾的隐藏输入的值Here's a fiddle
关于jquery - 找出最接近的隐藏输入字段,其ID以lkid结尾,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16687331/