<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();


获取相对于idlkidselect结尾的隐藏输入的值

Here's a fiddle

关于jquery - 找出最接近的隐藏输入字段,其ID以lkid结尾,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16687331/

10-13 01:51