我都有以下HTML:通過它的類部分字符串選擇一個元素
<div id="divAreaId_1" class="SuppAreaParentDiv">
<input type="hidden" value="3" class="hdnMaxSelection_1" id="hdnMaxSelection_1">
<input type="checkbox" id="SuppItemId_2" class="chkSuppItem"> <br />
<input type="checkbox" id="SuppItemId_3" class="chkSuppItem"> <br />
<input type="checkbox" id="SuppItemId_4" class="chkSuppItem"> <br />
<input type="checkbox" id="SuppItemId_5" class="chkSuppItem"> <br />
我試圖得到'輸入:隱藏的價值,當任何複選框被選中!我需要通過做「輸入:隱藏」部分類別名稱:
$(".chkSuppItem").click(function() {
var hdnMaxSelection = $(this).prev("[class*='hdnMaxSelection_']").val();
alert(hdnMaxSelection); // I am getting here 'undefined'.