<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>
我需要获取最近隐藏字段的值,其中id以lkid结尾,并且在包含select的div中
答案 0 :(得分:5)
您可以使用attribute ends with selector:
$('#selectedAccountId').siblings('input[type="hidden"][id$="lkid"]').val();
获取隐藏输入的值id
结束lkid
相对于select
答案 1 :(得分:1)
答案 2 :(得分:1)
$(this).closest('div').find("input[id$='lkid']:hidden:first").val();