我有這個html代碼。我想通過輸入值獲取id值。 例如:我想知道具有value = number2 =>的id值這是unknown2。我怎樣才能做到這一點與jQuery?通過其他有價值的元素查找元素ID
<th id="unknown1" rel="0">
<input id="btnSendMessage" type="button" value=number1 class="red"/>
</th>
<th id="unknown2" rel="0">
<input id="btnSendMessage" type="button" value=number2 class="red"/>
</th>
<th id="unknown3" rel="0">
<input id="btnSendMessage" type="button" value=number3 class="red"/>
</th>
$(「input [value ='number2']」)。parent()。attr('id') –