我幾乎總是jquery noob我很害怕!我相信這是一件非常簡單的事情,但我似乎無法解決這個問題。使用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();
有人能告訴我什麼,我做錯了什麼?
感謝
您將updateAmount()放在文檔中準備好了嗎? – JonathanRomer
你會想要警報來嗎?當你點擊收音機 –