我有一個<table>
和一些行(取決於運行查詢),在那裏我可以一個單選按鈕和一些<th>
和<input>
,我想趕上那班作進一步處理<input>
值,請指導我獲取的<input>元素值
我的HTML代碼
<tr>
<th>
<input type="radio" name="assignRadio">
</th>
<th> <?= $nearestResponders[ $i ]->get('firstName') . " " . $nearestResponders[ $i ]->get('lastName'); ?></th>
<th> <?= $companyName; ?></th>
<th> <?= $nearestResponders[ $i ]->get('contactNumber'); ?></th>
<th> <?= $presentCity; ?></th>
<th><?= $distanceInKM; ?></th>
<input class="selectedResponder" type="hidden" value="<?= $nearestResponders[ $i ]->getObjectId(); ?>">
</tr>
</table>
我jQuery代碼
$('input[name=assignRadio]').on('change',function(){
console.log($(this).val());
console.log($(this).next('.selectedResponder').val());
console.log($(this).closest('.selectedResponder').val());
console.log($(this).find('.selectedResponder').val());
});
,你可以看到我嘗試了一些方法來獲取價值,但失敗了,所以請指教
不要包含你的PHP文件,而實際上得到最終的HTML並粘貼在這裏。製作可複製的jsfiddle或snippet會有所幫助。 –