恐怕我几乎是一个完全的 jquery 菜鸟!我确信这是一件非常简单的事情,但我似乎无法解决。
我正在尝试获取动态的选定单选按钮的值。
HTML...
<div id="holder" class="">
<table id="qual-holder" class="table table-striped qual-table">
<thead>
<tr>
<th>Sector</th>
<th>Qualification Title</th>
<th>Cost</th>
<th>Confirm</th>
</tr>
</thead>
<tr class="sector_qual">
<td>OM207</td>
<td>Diploma in Children and Young People's Workforce Level 3</td>
<td>0</td>
<td>
<input name="qualification" id="28" type="radio" value="28" class="">
</td>
</tr>
<tr class="sector_qual">
<td>OM207</td>
<td>Diploma in Children and Young People's Workforce</td>
<td>0</td>
<td>
<input name="qualification" id="29" type="radio" value="29" class="">
</td>
</tr>
<tbody id="sector_quals"></tbody>
</table>
<div class="control-group spacing-top">
<label for="loan_value" class="control-label required">Amount to Borrow</label>
<div class="controls">
<div class="input-prepend"> <span class="add-on"><i class="icon-gbp"></i></span>
<input class="input-small" placeholder="" name="loan_value" type="text" value="" id="loan_value">
</div>
</div>
</div>
还有我的(垃圾)jQuery ......
function updateAmount() {
var selectedValue = "";
var selected = $("input:radio[name='qualification']:checked");
if (selected.length > 0) {
selectedValue = selected.val();
alert('The radio button has been selected and the value is.' + selectedValue);
}
}
updateAmount();
有人可以告诉我我做错了什么吗?
谢谢