發送隱藏字段的值,我使用下面的模板來顯示從數據庫中的數據。它被重複並且相同的類被多次使用。我想要傳遞該onclick
事件btnDelete
上該模板中隱藏字段的值。在jQuery的單擊事件
<div class="Template">
<div class="Title"></div>
<div class="Price"></div>
<div class="_Qty">Total Tickets:<div class="TotalQty"></div></div>
<div class="_Qty1">Sold Tickets:<div class="UsedQty"></div></div>
<div class="_Date">On Sale:<div class="StartDate"></div></div>
<div class="_Date1">Sale Ends:<div class="EndDate"></div></div>
<input type="hidden" value="8c991c10-7d88-4212-b931-5bfeff4ebcd0" />
<input type="button" class="btnDelete" value="Remove Ticket" onclick="fnRemoveTicket(**THIS IS WHERE I NEED TO PASS HID VALUE**);"/>
<input type="button" class="btnEdit" value="Edit Ticket"/>
</div>
我不知道如何傳遞與按鈕位於同一父級的隱藏字段的值。通常,我會選擇具有某種類型的獨特選擇器的按鈕。然後執行諸如$(this).closest
或$(this).parent
之類的操作。由於我對該按鈕沒有任何獨特之處,因此我必須將其與onclick
事件聯繫起來,但我不知道如何使其發揮作用。
謝謝,那會工作 –